blob: 45ba33df20e1d43c425944cf63d651fcdeacc583 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
{-# LANGUAGE TypeFamilies, StandaloneDeriving, FlexibleInstances, GADTs #-}
module Main where
import Data.Ix
-- Deriving Enum with phantom type parameter
data T a = R | S | T deriving( Enum, Show )
-- Tests that deriving works for data families
data family Foo a
data instance Foo Int
= A | B | C | D
deriving (Eq, Enum)
f :: Foo Int -> Bool
f A = True
f B = False
f _ = True
-- Tests that deriving works for GADTs
data Bar a where
P :: Int -> Bar Int
Q :: Bar Int
deriving instance (Eq (Bar Int))
main = do { print [R .. T]
; print (map f [B .. D])
; print [P 3 == P 3, P 4 == Q] }
|