1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 01:52:11 +03:00
juvix/app/Commands/Dev/Geb/Check.hs
Łukasz Czajka 3c3e442c81
End-to-end Geb compilation tests (#1942)
* Adds end-to-end tests for compiling Juvix to Geb
* Fixes bugs in the Core-to-Geb translation (`<=` and `let`)
* Fixes a bug in the Geb evaluator (equality on integers)
2023-03-29 14:02:40 +02:00

25 lines
902 B
Haskell

module Commands.Dev.Geb.Check where
import Commands.Base
import Commands.Dev.Geb.Infer.Options
import Juvix.Compiler.Backend.Geb qualified as Geb
import Juvix.Compiler.Backend.Geb.Analysis.TypeChecking.Error
runCommand ::
forall r.
(Member App r, Member (Embed IO) r) =>
GebInferOptions ->
Sem r ()
runCommand opts = do
let b :: SomeBase File
b = opts ^. gebInferOptionsInputFile . pathPath
f :: Path Abs File <- someBaseToAbs' b
content :: Text <- embed (readFile (toFilePath f))
case Geb.runParser f content of
Right (Geb.ExpressionTypedMorphism tyMorph) -> do
case run . runError @CheckingError $ (Geb.check' tyMorph) of
Left err -> exitJuvixError (JuvixError err)
Right _ -> renderStdOut ("Well done! It typechecks\n" :: Text)
Right _ -> exitJuvixError (error @JuvixError "Not a typed morphism")
Left err -> exitJuvixError (JuvixError err)