I have a project I am working on in Haskell that has me creating functions for a DSL. We are creating our own Types and using them to write various functions.
data Layer =
Bread Bread
| Meat Meat
| Cheese Cheese
| Vegetable Vegetable
| Condiment Condiment
deriving (Eq,Show)
data Bread = White | Wheat | Rye
deriving (Eq,Show)
What I am trying to do right now is implement an isBread function that takes a layer and returns true or false if it is bread or not.
isBread :: Layer -> Bool
isBread b | White = True
| Wheat = True
| Rye = True
| otherwise = False
With the above code, I get the error that it cannot match expected type 'Bool' with type 'Bread.
isBread :: Layer -> Bool
isBread b | Bool a = True while b = White
| Bool a = True while b = Wheat
| Bool a = True while b = Rye
| otherwise Bool a = False
I tried the above code next to try and return an actual Boolean but I got a parse error. I dont know if my syntax is off but it seems like it should do what I want. Any suggestions?
data Layer = Bread String | Meat Stringand try writingisBreadfor it. - n. 1.8e9-where's-my-share m.