add repr function
This commit is contained in:
parent
9672c5fb8f
commit
604b2e3148
1 changed files with 2 additions and 0 deletions
|
@ -142,6 +142,7 @@ _putstr str@(StrV _) = _fputstr $ TupleV [StreamV 0, str]
|
||||||
_getline UnitV = _fgetline (StreamV 1)
|
_getline UnitV = _fgetline (StreamV 1)
|
||||||
|
|
||||||
_print v = _putstr $ StrV $ show v ++ "\n"
|
_print v = _putstr $ StrV $ show v ++ "\n"
|
||||||
|
_repr v = return . StrV $ show v
|
||||||
|
|
||||||
_itos (IntV i) = return $ StrV $ show i
|
_itos (IntV i) = return $ StrV $ show i
|
||||||
_itos v = error $ "itos: not an int: " ++ show v
|
_itos v = error $ "itos: not an int: " ++ show v
|
||||||
|
@ -156,6 +157,7 @@ _loop fn@(FnV _ _) = _loop $ TupleV [fn, UnitV]
|
||||||
initialState = ([stdout, stdin],
|
initialState = ([stdout, stdin],
|
||||||
[M.fromList [("id", FnV emptyEnv [(VarP "x", Var "x")]),
|
[M.fromList [("id", FnV emptyEnv [(VarP "x", Var "x")]),
|
||||||
("loop", Builtin $ BIF _loop),
|
("loop", Builtin $ BIF _loop),
|
||||||
|
("repr", Builtin $ BIF _repr),
|
||||||
("stdout", StreamV 0),
|
("stdout", StreamV 0),
|
||||||
("stdin", StreamV 1),
|
("stdin", StreamV 1),
|
||||||
("print", Builtin $ BIF _print),
|
("print", Builtin $ BIF _print),
|
||||||
|
|
Loading…
Reference in a new issue