From dea4093865a0ce380ecee660af93db4a170b8f1e Mon Sep 17 00:00:00 2001 From: olemorud Date: Sun, 7 May 2023 20:35:39 +0200 Subject: [PATCH] Add function run --- forth.hs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/forth.hs b/forth.hs index 2e7c886..2f31ba3 100644 --- a/forth.hs +++ b/forth.hs @@ -35,6 +35,9 @@ emptyState = ForthState [] evalText :: Text -> ForthState -> Either ForthError ForthState 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, -- probably a better way to do this runParsed :: a -> [a -> Either b a] -> Either b a