mirror of
https://github.com/anoma/juvix.git
synced 2024-12-19 04:41:36 +03:00
c9b8cdd5e9
This implements a basic version of the algorithm from: Luc Maranget, [Compiling pattern matching to good decision trees](http://moscova.inria.fr/~maranget/papers/ml05e-maranget.pdf). No heuristics are used - the first column is always chosen. * Closes #1798 * Closes #1225 * Closes #1926 * Adds a global `--no-coverage` option which turns off coverage checking in favour of generating runtime failures * Changes the representation of Match patterns in JuvixCore to achieve a more streamlined implementation * Adds options to the Core pipeline
27 lines
1.2 KiB
Haskell
27 lines
1.2 KiB
Haskell
module Commands.Dev.Core.Strip where
|
|
|
|
import Commands.Base
|
|
import Commands.Dev.Core.Strip.Options
|
|
import Juvix.Compiler.Core.Options qualified as Core
|
|
import Juvix.Compiler.Core.Pipeline qualified as Core
|
|
import Juvix.Compiler.Core.Pretty qualified as Core
|
|
import Juvix.Compiler.Core.Translation.FromSource qualified as Core
|
|
import Juvix.Compiler.Core.Translation.Stripped.FromCore qualified as Stripped
|
|
|
|
runCommand :: forall r a. (Members '[Embed IO, App] r, CanonicalProjection a Core.Options, CanonicalProjection a CoreStripOptions) => a -> Sem r ()
|
|
runCommand opts = do
|
|
gopts <- askGlobalOptions
|
|
inputFile :: Path Abs File <- someBaseToAbs' sinputFile
|
|
s' <- embed (readFile $ toFilePath inputFile)
|
|
(tab, _) <- getRight (mapLeft JuvixError (Core.runParser inputFile Core.emptyInfoTable s'))
|
|
let r =
|
|
run $
|
|
runReader (project gopts) $
|
|
runError @JuvixError (Core.toStripped' tab :: Sem '[Error JuvixError, Reader Core.CoreOptions] Core.InfoTable)
|
|
tab' <- getRight $ mapLeft JuvixError $ mapRight Stripped.fromCore r
|
|
unless (project opts ^. coreStripNoPrint) $ do
|
|
renderStdOut (Core.ppOut opts tab')
|
|
where
|
|
sinputFile :: SomeBase File
|
|
sinputFile = project opts ^. coreStripInputFile . pathPath
|