Add function run

This commit is contained in:
olemorud
2023-05-07 20:35:39 +02:00
parent 7a855e9790
commit dea4093865

View File

@@ -35,6 +35,9 @@ emptyState = ForthState []
evalText :: Text -> ForthState -> Either ForthError ForthState evalText :: Text -> ForthState -> Either ForthError ForthState
evalText t state = runParsed state $ parseWords t evalText t state = runParsed state $ parseWords t
run :: String -> Either ForthError ForthState
run str = evalText (T.pack str) emptyState
-- like foldl but applies a lists of functions that return Eithers to acc, -- like foldl but applies a lists of functions that return Eithers to acc,
-- probably a better way to do this -- probably a better way to do this
runParsed :: a -> [a -> Either b a] -> Either b a runParsed :: a -> [a -> Either b a] -> Either b a