I am new to haskell & i was trying to filter elements from a created Data Type called Hoover.
Now a Hoover has a Price & a Wattage , I defined Hoover as :
data Hoover = HH Price Wattage
& Price & Wattage as :
data Price = P Int
data Wattage = W Int
When i try to run this code for filtering the hoovers from a catalog of differently priced Hoovers :
(Here m is the minimum price and n is the maximum price) :
filterProduct :: Price -> Price -> [Hoover] -> [Hoover]
filterProduct (P m) (P n) [] = []
filterProduct (P m) (P n) (x:xs) = if(price >= m && price <= n) then ([x] ++ (filterProduct (P m) (P n) xs))
else (filterProduct (P m) (P n) xs)
where
x :: Hoover
x = HH (P price) watt
I get quite a lot of errors, i tried to do a lot of things but couldn't get around it & needed help fixing it
Would appreciate any help !