Skip to content

Instantly share code, notes, and snippets.

@max630
Created December 21, 2011 07:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save max630/1505056 to your computer and use it in GitHub Desktop.
Save max630/1505056 to your computer and use it in GitHub Desktop.
Уточнение типа по мере продвижения по файлу
{-# LANGUAGE TemplateHaskell #-}
module H where
import Language.Haskell.TH
f = [42]
$(do
i <- reify (mkName "f")
runIO (print i)
sequence [dataD (cxt []) (mkName "A") [] [normalC (mkName "A") []] []])
main = do
case f :: [Integer] of
[42] -> print "A"
_ -> print "B"
$(do
i <- reify (mkName "f")
runIO (print i)
sequence [dataD (cxt []) (mkName "B") [] [normalC (mkName "B") []] []])
VarI H.f (AppT ListT (VarT t_1946157057)) Nothing (Fixity 9 InfixL)
VarI H.f (AppT ListT (ConT GHC.Integer.Type.Integer)) Nothing (Fixity 9 InfixL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment