[Haskell-cafe] Haskell type declaration summary

Andrew Butterfield Andrew.Butterfield at scss.tcd.ie
Thu May 4 16:09:53 UTC 2017


Hi Kevin,
 yes - I can do that, but it is tedious to issue each command, and I may not remember what all the types are called
(I know that :browse will tell me what things exist in the current module with a capital letter)

Also I want to be able to do this for a file different to the one currently loaded in GHCi.

Something along the lines of (assuming a unix shell):

$> showtypes MyBigMonsterHaskellFile.hs
data X = A | B
type Name = String
newtype Y = Z Name
....
$>

(maybe with a blank line for each one..)
Has no-one rustled up something like this - or do I need to look into Haskell parsing...?

Cheers, Andrew

> On 4 May 2017, at 16:30, Kevin Quick <quick at sparq.org> wrote:
> 
> 
> You can use ghci's browse:
> 
> $ ghci
> Prelude> import Data.Maybe
> Prelude Data.Maybe> :browse Data.Maybe
> ...
> Prelude Data.Maybe> :l MyFile.hs
> MyFile Data.Maybe> :browse MyFile
> ...
> 
> Andrew Butterfield writes:
> 
>> Dear Haskellers,
>> any quick and easy way to extract all the type declarations from a Haskell source file?
>> (for easy reference)
>> 
>> Regards,
>> 
>> Andrew Butterfield
>> School of Computer Science & Statistics
>> Trinity College
>> Dublin 2, Ireland
>> 
>> _______________________________________________
>> Haskell-Cafe mailing list
>> To (un)subscribe, modify options or view archives go to:
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
>> Only members subscribed via the mailman list are allowed to post.
> 

Andrew Butterfield
School of Computer Science & Statistics
Trinity College
Dublin 2, Ireland



More information about the Haskell-Cafe mailing list