I'm writing this small program basically to identify each input tokens as operator/parenthesis/int.
However, I encountered a problem stating that
Not in scope: data constructor `Integer'
Here's what I have so far (
Data.Char only defines
isDigit, nothing else)
import Data.Char (isDigit) data Token = TPlus | TTimes | TParenLeft | TParenRight | TNumber Integer | TError deriving (Show, Eq) tokenize :: String -> [Token] tokenize  =  tokenize (c:cs) | c == '+' = TPlus : tokenize cs | c == '*' = TTimes : tokenize cs | c == '(' = TParenLeft : tokenize cs | c == ')' = TParenRight : tokenize cs | isDigit c = TNumber Integer (read c) : tokenize cs | otherwise = TError : tokenize cs
Some example expected output:
*Main> tokenize "( 1 + 2 )"
[TParenLeft,TNumber 1,TPlus,TNumber 2,TParenRight]
*Main> tokenize "abc"
TError, but I'm getting
I'd appreciate if anyone could shed some light on these two issues.