I have my own data type that states:
data Commands = MoveLeft |
MoveRight |
MoveUp |
MoveDown |
IfVertical |
IfHorizontal |
InputChar |
InputInt |
OutputChar |
OutputInt |
OutputNewline |
PushInt Int |
Add |
Sub |
Mult |
Div |
Exp |
Pop |
Dup |
Switch |
Noop |
End
deriving (Show, Eq)
and I have a function with which I am trying to extract a number from PushIntwith:
extractNum :: PushInt -> Int
extractNum (PushInt n) = n
But when I try to run this, I get an error message:
Parser.hs:32:19:
Not in scope: type constructor or class `PushInt'
A data constructor of that name is in scope; did you mean -XDataKinds?
As far as I knew, I was allowed to retrieve a field from the data using this method. I am sure this is just a very simple mistake, but any help is appreciated.
source
share