on 0.11.2.0-r2 help sign in
36 lines 1.1 kB history raw
1{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE GADTs #-}
3{-# LANGUAGE GeneralizedNewtypeDeriving #-}
4{-# LANGUAGE StandaloneDeriving #-}
5{-# LANGUAGE TypeFamilies #-}
7module DataFamilies.Types where
9import Types (ApproxEq(..))
11data family Nullary a
12data instance Nullary Int = C1 | C2 | C3 deriving (Eq, Show)
13data instance Nullary Char = C4 deriving (Eq, Show)
15data family SomeType a b c
16data instance SomeType c () a = Nullary
17 | Unary Int
18 | Product String (Maybe Char) a
19 | Record { testOne :: Double
20 , testTwo :: Maybe Bool
21 , testThree :: Maybe a
22 } deriving (Eq, Show)
24data family Approx a
25newtype instance Approx a = Approx { fromApprox :: a }
26 deriving (Show, ApproxEq, Num)
28instance (ApproxEq a) => Eq (Approx a) where
29 Approx a == Approx b = a =~ b
31data family GADT a
32data instance GADT a where
33 GADT :: { gadt :: String } -> GADT String
35deriving instance Eq (GADT a)
36deriving instance Show (GADT a)