API for looking-up/retrieving Haddock comments?
marlowsd at gmail.com
Wed Aug 8 13:12:46 CEST 2012
On 04/08/2012 08:33, Herbert Valerio Riedel wrote:
> Simon Hengel <sol at typeful.net> writes:
>> I have the following in my .ghci:
>> -- hoogle integration
>> :def hoogle \q -> return $ ":! hoogle --color=true --count=15 \"" ++ q ++ "\""
>> :def doc \q -> return $ ":! hoogle --color=true --info \"" ++ q ++ "\""
> thanks, this already looks very promising; there's just a few minor issues
> I'm a bit dissatisfied with the GHCi integration:
> 1. it doesn't take into account the currently visible module namespaces that GHCi
> has currently loaded (as opposed to `:info` and `:type`):
> | Prelude> import Data.IntMap
> | Prelude Data.IntMap> :info fromList
> | fromList :: [(Key, a)] -> IntMap a -- Defined in `Data.IntMap'
> | Prelude Data.IntMap> :type fromList
> | fromList :: [(Key, a)] -> IntMap a
> | Prelude Data.IntMap> :doc fromList
> | Searching for: fromList
> | Data.HashTable fromList :: Eq key => (key -> Int32) -> [(key, val)] -> IO (HashTable key val)
> | Convert a list of key/value pairs into a hash table. Equality on keys
> | is taken from the Eq instance for the key type.
> | From package base
> | fromList :: Eq key => (key -> Int32) -> [(key, val)] -> IO (HashTable key val)
> | Prelude Data.IntMap>
> 2. tab-completion (as it works for `:type` and `:doc`) doesn't extend
> to `:doc`
> I guess both items could be improved upon by extending GHCi to provide
> an additional `:def` facility tailored to Haskell symbols allowing to
> pass more meta-information (such as package and module information) into
> the resulting command string... would something like that have any
> chance of being accepted upstream?
I think it would make more sense to just add :doc to the GHCi front-end,
relying on the user having already installed hoogle. We could give a
sensible error message if you don't have Hoogle installed.
More information about the Glasgow-haskell-users