I am a new learner in Haskell, the notion of Mutually recursive types confused me a lot.
Here is an example:
data BoolExpr
= BoolConst Bool
| BoolOp BoolOp BoolExpr BoolExpr
| ConpOp CompOp IntExpr IntExpr
Why here are two BoolOp and CompOp?
I know that the first BoolOp is a data constructor, but how about the second BoolOp?
You’re right that the first
BoolOpis a constructor; the second says that the constructor takes a value of type:: BoolOp. The full type is:So I’d expect there’s some code like this lying around:
So to use this constructor, you’d need to give it a
BoolOpand twoBoolExprs: