Skip to content

Commit

Permalink
Simplify interpret.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Grant Jeffries committed Nov 2, 2019
1 parent 65a1f2d commit 9728c3a
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions bowtie/src/Bowtie/Interpret.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ("<input>", src)

interpretProgram
:: HashMap FilePath Text
Expand All @@ -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
Expand Down

0 comments on commit 9728c3a

Please sign in to comment.