fix itos to error on non-int inputs
This commit is contained in:
parent
d36f589132
commit
83111e51fb
|
@ -66,12 +66,15 @@ _getline UnitV = do
|
||||||
{-# NOINLINE unsafe_getline #-}
|
{-# NOINLINE unsafe_getline #-}
|
||||||
unsafe_getline h = unsafePerformIO $ hGetLine h
|
unsafe_getline h = unsafePerformIO $ hGetLine h
|
||||||
|
|
||||||
|
_itos (IntV i) = return $ StrV $ show i
|
||||||
|
_itos v = error $ "itos: not an int: " ++ show v
|
||||||
|
|
||||||
initialState = ([stdout, stdin],
|
initialState = ([stdout, stdin],
|
||||||
M.fromList [("id", FnV [(VarP "x", [Var "x"])]),
|
M.fromList [("id", FnV [(VarP "x", [Var "x"])]),
|
||||||
("stdout", StreamV 0),
|
("stdout", StreamV 0),
|
||||||
("putstr", Builtin $ BIF _putstr),
|
("putstr", Builtin $ BIF _putstr),
|
||||||
("putstrln", Builtin $ BIF (\x -> _putstr $ x +$ StrV "\n")),
|
("putstrln", Builtin $ BIF (\x -> _putstr $ x +$ StrV "\n")),
|
||||||
("itos", Builtin $ BIF (\(IntV i) -> return $ StrV $ show i)),
|
("itos", Builtin $ BIF _itos),
|
||||||
("getline", Builtin $ BIF _getline)])
|
("getline", Builtin $ BIF _getline)])
|
||||||
|
|
||||||
eval :: AST -> InterpState Value
|
eval :: AST -> InterpState Value
|
||||||
|
|
Loading…
Reference in New Issue