Created
August 2, 2013 23:07
-
-
Save davdar/6144184 to your computer and use it in GitHub Desktop.
small example that breaks GHC type safety by combining GADTs and TypeFamilies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# 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