Interp: cons works on strings

This commit is contained in:
darkf 2015-01-17 00:52:12 -08:00
parent 92594900b4
commit eef1c17def
1 changed files with 5 additions and 1 deletions

View File

@ -272,7 +272,11 @@ eval (Cons a b) = do
b' <- eval b
case b' of
ListV v' -> return $ ListV $ a':v'
_ -> error "cons: RHS must be a list"
StrV v' ->
case a' of
StrV c | T.length c == 1 -> return $ StrV $ T.cons (T.head c) v'
_ -> error "cons: LHS must be a char"
_ -> error "cons: RHS must be a list or string"
eval (ListConst v) = ListV <$> mapM eval v
eval (TupleConst v) = TupleV <$> mapM eval v