Skip to content

Instantly share code, notes, and snippets.

@igrep
Last active June 19, 2016 04:06
Show Gist options
  • Select an option

  • Save igrep/8c96196cddbc14f840fe0cd202bd6bff to your computer and use it in GitHub Desktop.

Select an option

Save igrep/8c96196cddbc14f840fe0cd202bd6bff to your computer and use it in GitHub Desktop.
Example result of Language.Haskell.TH.reify
stack exec ghci -- -XTemplateHaskell
:m Language.Haskell.TH
data A = A { a :: Int, b :: String }
$(stringE . show =<< reify 'A)
-- prettified output
DataConI
Ghci12.A ( -- DataConI/Name
AppT ( -- DataConI/Type
AppT ArrowT ( -- DataConI/Type/Type
ConT GHC.Types.Int -- DataConI/Type/Type/Type
)
) ( -- DataConI/Type
AppT ( -- DataConI/Type/Type
AppT ArrowT ( -- DataConI/Type/Type/Type
ConT GHC.Base.String -- DataConI/Type/Type/Type/Type
)
) (
ConT Ghci12.A -- DataConI/Type/Type/Type
)
)
)
Ghci12.A -- DataConI/ParentName
(
Fixity 9 InfixL -- DataConI/Fixity
)
$(stringE . show =<< reify ''A)
-- prettified output
TyConI (
DataD -- TyConI/DataD
[] -- TyConI/DataD/Cxt
Ghci12.A -- TyConI/DataD/Name
[] -- TyConI/DataD/[TyVarBndr]
[ -- TyConI/DataD/[Con]
RecC -- TyConI/DataD/[Con]/RecC
Ghci12.A -- TyConI/DataD/[Con]/RecC/Name
[ -- TyConI/DataD/[Con]/RecC/Name/VarStrictType
(
Ghci12.a,
NotStrict,
ConT GHC.Types.Int
),
(
Ghci12.b,
NotStrict,
ConT GHC.Base.String
)
]
]
[] -- TyConI/DataD/[Name]
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment