fix itos to error on non-int inputs

This commit is contained in:
darkf 2013-10-20 17:25:38 -07:00
parent d36f589132
commit 83111e51fb
1 changed files with 4 additions and 1 deletions

View File

@ -66,12 +66,15 @@ _getline UnitV = do
{-# NOINLINE unsafe_getline #-}
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],
M.fromList [("id", FnV [(VarP "x", [Var "x"])]),
("stdout", StreamV 0),
("putstr", Builtin $ BIF _putstr),
("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)])
eval :: AST -> InterpState Value