I have a problem in this code:
module Blueprint where
data Colour = Blue | Green | Red
deriving ( Eq, Show )
data Car = Car { wheels :: Integer
, colour :: Colour
}
deriving ( Eq, Show )
data Property = Colour_Is Colour
| Wheels Ordering Integer
| And Property Property
| Not Property
| Or Property Property
deriving Show
check :: Property -> Car -> Bool
check prop car = case prop of
Colour_Is col -> col == colour car
Wheels ord num -> case ord of
LT -> num > wheels car
EQ -> num == wheels car
And l r -> check l car && check r car
Not p -> not check p car
Or x y -> check x car || check y car
cars = [ Car { wheels = 4, colour = Red }
, Car { wheels = 2, colour = Blue }
, Car { wheels = 14, colour = Green }
, Car { wheels = 4, colour = Green }
, Car { wheels = 2, colour = Red }
]
prop1 :: Property
prop1 = And (Wheels EQ 14) (Colour_Is Green)
test :: Bool
test = and
[ check ( Wheels EQ 4 ) ( cars !! 0 )
, check ( Wheels LT 3 ) ( cars !! 1 )
, check ( And ( Wheels EQ 14 ) ( Colour_Is Green )) ( cars !! 2 )
, check ( Not ( Colour_Is Red ) ) ( cars !! 3 )
, filter ( check prop1 ) cars == take 3 cars
]
I built the check function and implemented Colour_Is,And,Not and Wheels correctly, but when I add the Or function:
( Or x y -> check x car || check y car )
I'm getting this error from ghci :
D:\My_data\hs\strategy.hs:26:16: parse error on input `->' Failed, modules loaded: none.
I'm new to Haskell. Where is my mistake?