From 83111e51fb7bce002859d8fbe07e15c7d70320a4 Mon Sep 17 00:00:00 2001 From: darkf Date: Sun, 20 Oct 2013 17:25:38 -0700 Subject: [PATCH] fix itos to error on non-int inputs --- interp.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/interp.hs b/interp.hs index 2fad473..082f307 100644 --- a/interp.hs +++ b/interp.hs @@ -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