Print the resulting data type declaration of explicitly instantiated type parameters using the :info command in ghci
Assume the following code is loaded into GHCi:
data Foo a = Blah1 (XXBlah1 a) | Blah2 (XXBlah2 a)
type family XXBlah1 a where
XXBlah1 Int = String
XXBlah1 String = Bool
type family XXBlah2 a where
XXBlah2 Char = String
XXBlah2 String = Int
The user can write :info Foo
and then GHCi will print the following to the screen:
type role Foo nominal
type Foo :: * -> *
data Foo a = Blah1 (XXBlah1 a) | Blah2 (XXBlah2 a)
-- Defined at /Users/artin/Programming/ghciinfocommand.hs
It would be pretty useful if we could write:
:info (Foo String)
and get:
data Foo String = Blah1 Bool | Blah2 Int
(The parenthesis is needed, because if not explicitly written, the info command will print the info of Foo
and String
separately.
I find myself looking for this feature whenever I'm working with TTG data types.