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'm trying to extract the number from the PushInt with:
extractNum :: PushInt -> Int
extractNum (PushInt n) = n
But when I try to run this, I get an error stating:
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 extract a field from data with this method. I'm pretty sure that this is just a really simple mistake, but any help is appreciated.
Wow, was I right about a 2 am mistake. The function
extractNum :: PushInt -> Int
extractNum (PushInt n) = n
should be
extractNum :: Commands -> Int
extractNum (PushInt n) = n
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With