Skip to content

Instantly share code, notes, and snippets.

@mpickering
Created November 5, 2018 15:09
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mpickering/959a95525647802414ab50e8e6ed490c to your computer and use it in GitHub Desktop.
module A where
class C a where
foo :: a -> String
instance C Int where
foo _ = "int"
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
module B where
import A
import Language.Haskell.TH
instance C a => C [a] where
foo _ = "list"
me :: Q (TExp ([Int] -> String))
me = [|| foo ||]
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
module C where
import A
import Language.Haskell.TH
instance {-# OVERLAPPING #-} C [Int] where
foo _ = "list2"
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
module D where
import A
import B
import C
main2 = $$(me) [1 :: Int]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment