Haskell不在范围内:键入构造函数或类"PushInt"

Aea*_*nus 4 haskell types scope

我有自己的数据类型,表明:

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)
Run Code Online (Sandbox Code Playgroud)

我有一个函数,我正试图从中提取数字PushInt:

extractNum :: PushInt -> Int
extractNum (PushInt n) = n
Run Code Online (Sandbox Code Playgroud)

但是当我尝试运行它时,我收到一个错误说明:

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?
Run Code Online (Sandbox Code Playgroud)

据我所知,我被允许使用这种方法从数据中提取字段.我很确定这只是一个非常简单的错误,但任何帮助都表示赞赏.

Aea*_*nus 9

哇,我对凌晨2点的错误是正确的.功能

extractNum :: PushInt -> Int
extractNum (PushInt n) = n
Run Code Online (Sandbox Code Playgroud)

应该

extractNum :: Commands -> Int
extractNum (PushInt n) = n
Run Code Online (Sandbox Code Playgroud)