I have the following data structure:
data Exp
= Var String
| Unary
{ exp :: Exp
, op :: UnaryOp}
| Binary
{ left :: Exp
, right :: Exp
, op :: BinaryOp
}
data UnaryOp = Not
data BinaryOp = And | Or | Impl | Equal
And I get the following error:
Constructors Binary and Unary give different types for field ‘op’
But I dont get why the different types for the op make a problem. They are in records of diffrent variants. They should be independent things shouldnt they ?