Skip to content

Instantly share code, notes, and snippets.

@davdar
Created August 2, 2013 23:07
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 davdar/6144184 to your computer and use it in GitHub Desktop.
Save davdar/6144184 to your computer and use it in GitHub Desktop.
small example that breaks GHC type safety by combining GADTs and TypeFamilies
{-# LANGUAGE TypeFamilies, GeneralizedNewtypeDeriving #-}
module Test where
newtype Age = Age Int
deriving (Foo)
type family F a :: *
type instance F Int = Int
type instance F Age = Bool
class Foo a where
foo :: a -> F a -> Double
instance Foo Int where
foo _ = intToDouble
where
intToDouble :: Int -> Double
intToDouble = fromIntegral
main :: IO ()
main = do
putStrLn $ show $ foo (Age 1) True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment