Modify a couple of error messages slightly
[ghc.git] / testsuite / tests / gadt / Gadt17_help.hs
1 {-# LANGUAGE GADTs #-}
2 {-# OPTIONS_GHC -O #-}
3
4 module Gadt17_help (
5 TernOp (..), applyTernOp
6 ) where
7
8 data TypeWitness a where
9 TWInt :: TypeWitness Int
10 TWBool :: TypeWitness Bool
11 TWFloat :: TypeWitness Float
12 TWDouble :: TypeWitness Double
13
14 instance (Eq a) => Eq (TypeWitness a) where
15 (==) TWInt TWInt = True
16 (==) TWBool TWBool = True
17 (==) TWFloat TWFloat = True
18 (==) TWDouble TWDouble = True
19 (==) _ _ = False
20
21 data TernOp a b c d where
22 OpIf :: TypeWitness a -> TernOp Bool a a a
23 OpTernFunc :: TypeWitness a -> TypeWitness b -> TypeWitness c
24 -> TypeWitness d -> (a -> b -> c -> d) -> TernOp a b c d
25
26 instance Show (TernOp a b c d) where
27 show (OpIf {}) = "OpIf"
28 show (OpTernFunc {}) = "OpTernFunc <function>"
29
30
31 applyTernOp :: TernOp a b c d -> a -> b -> c -> d
32 applyTernOp (OpIf {}) cond x y = if (cond) then x else y
33 applyTernOp (OpTernFunc _ _ _ _ f) x y z = f x y z
34