From 9728c3ae818ef10275d3823f6193b0468ce04975 Mon Sep 17 00:00:00 2001 From: Ian Grant Jeffries Date: Sat, 2 Nov 2019 13:57:32 -0400 Subject: [PATCH] Simplify interpret. --- bowtie/src/Bowtie/Interpret.hs | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/bowtie/src/Bowtie/Interpret.hs b/bowtie/src/Bowtie/Interpret.hs index b96c9f2..d19b1bb 100644 --- a/bowtie/src/Bowtie/Interpret.hs +++ b/bowtie/src/Bowtie/Interpret.hs @@ -19,20 +19,15 @@ import qualified Data.Bifunctor as Bifunctor import qualified Data.Text as Text import qualified Text.Megaparsec as Mega +data IError + = ParseError ParserErrorBundle + | NameClash Text + | TypeError TypeError + deriving (Eq, Show) + interpret :: Text -> Either IError Untyped.Expr interpret src = do - (_, core) <- sourceToCore src - let - untyped :: Untyped.Expr - untyped = - Untyped.Erase.erase core - - case Untyped.Eval.eval mempty untyped of - Left e -> - panic ("Evaluating failed (this should never happen): " <> show e) - - Right a -> - pure a + interpretProgram mempty ("", src) interpretProgram :: HashMap FilePath Text @@ -52,12 +47,6 @@ interpretProgram libFiles appFile = do Right a -> pure a -data IError - = ParseError ParserErrorBundle - | NameClash Text - | TypeError TypeError - deriving (Eq, Show) - prettyError :: IError -> Text prettyError err = case err of