Finding out which module a function belongs to
ghci, haskell
Solution
You want the `:i` command (short for `:info`).
Prelude> :i take
take :: Int -> [a] -> [a] -- Defined in GHC.List
Prelude> :i sort
Top level: Not in scope: `sort'
Prelude> :m +Data.List
Prelude Data.List> :i sort
sort :: Ord a => [a] -> [a] -- Defined in Data.List
As you suggest, it only works if the function is in a currently loaded module.
Note that you are told which module the function is originally defined in. e.g. `take` is defined in `GHC.List` (at least in my copy of ghc), but re-exported from the prelude. You are not told which module(s) you imported it from.
Problem
In ghci (haskell) is there a command which will tell me which module (out of the loaded modules) a function belongs to. e.g. if the function is called whichMod, then it would work as follows : ``` Prelude>whichMod take Prelude Prelude>whichMod sort Data.List ```