Ticket #2238: FDvsTF.hs

File FDvsTF.hs, 646 bytes (added by claus, 6 years ago)
Line 
1{-# LANGUAGE TypeFamilies #-}
2{-# LANGUAGE UndecidableInstances #-}
3{-# LANGUAGE FlexibleInstances #-}
4{-# LANGUAGE EmptyDataDecls #-}
5{-# LANGUAGE FunctionalDependencies #-}
6{-# LANGUAGE MultiParamTypeClasses #-}
7
8data A
9data B
10
11-- via functional dependencies
12
13class HowFD a how | a -> how
14
15class HowFD a how => CFD a how where 
16  cfd :: a -> String 
17  cfd _ = "cfd"
18instance HowFD a how => CFD a how
19
20instance HowFD Bool A
21
22-- via type families
23
24type family HowTF a
25
26class how ~ HowTF a => CTF a how where 
27  ctf :: a -> String
28  ctf _ = "ctf"
29-- instance how ~ HowTF a => CTF a how
30
31type instance HowTF Bool = A