-lex [x:xs]
-# t = get x SingleCharTokens
-| isJust t = (Right (fromJust t), xs)
-| isSpace x = lex xs
-| isDigit x = let (is, xs`) = span isDigit xs in
- (Right (NumberToken [x:is]), xs`)
-| isAlpha x = let (is, xs`) = span (\c.isAlphanum c || c == '_') xs in
- (Right (IdentToken [x:is]), xs`)
-| otherwise = (Left ("Unexpected character: " +++ toString x), [])
+lex ['-':t=:[x:xs]]
+| isDigit x = let (i, r) = span isDigit t in (Right (NumberToken ['-':i]), r)
+| otherwise = (Right DashToken, xs)
+lex t=:[x:xs] = case get x SingleCharTokens of
+ (Just tok) = (Right tok, xs)
+ Nothing
+ | isSpace x = lex xs
+ | isDigit x = let (i, r) = span isDigit t in (Right (NumberToken i), r)
+ | isAlpha x = let (i, r) = span isIdent t in (Right (IdentToken i), r)
+ with isIdent c = isAlphanum c || c == '_'
+ | otherwise = (Left ("Unexpected character: " +++ toString x), [])