1
1
mirror of https://github.com/anoma/juvix.git synced 2025-01-05 22:46:08 +03:00
juvix/app/Commands/MicroJuvix.hs
janmasrovira 2cf3f85439
Support implicit arguments (#144)
* work in progress towards implicit arguments

* Wip towards implicit types

* improve arity checker

* Add version of SimpleFungibleToken with implicit arguments

* guess arity of body before checking the lhs of a clause

* add ArityUnknown and fix some tests

* wip: proper errors in arity checker

* fix bugs, improve errors and add tests

* format

* set hlint version to 3.4 in the ci

* update pre-commit version to 3.0.0

* minor changes

* added more revisions

* minor

Co-authored-by: Jonathan Cubides <jonathan.cubides@uib.no>
2022-06-13 14:25:22 +02:00

61 lines
1.6 KiB
Haskell

module Commands.MicroJuvix where
import MiniJuvix.Prelude hiding (Doc)
import Options.Applicative
data MicroJuvixCommand
= Pretty
| TypeCheck MicroJuvixTypeOptions
| Arity
newtype MicroJuvixTypeOptions = MicroJuvixTypeOptions
{ _microJuvixTypePrint :: Bool
}
makeLenses ''MicroJuvixTypeOptions
parseMicroJuvixCommand :: Parser MicroJuvixCommand
parseMicroJuvixCommand =
hsubparser $
mconcat
[ commandPretty,
commandArity,
commandTypeCheck
]
where
commandArity :: Mod CommandFields MicroJuvixCommand
commandArity = command "arity" arityInfo
commandPretty :: Mod CommandFields MicroJuvixCommand
commandPretty = command "pretty" prettyInfo
commandTypeCheck :: Mod CommandFields MicroJuvixCommand
commandTypeCheck = command "typecheck" typeCheckInfo
arityInfo :: ParserInfo MicroJuvixCommand
arityInfo =
info
(pure Arity)
(progDesc "Translate a MiniJuvix file to MicroJuvix and insert holes")
prettyInfo :: ParserInfo MicroJuvixCommand
prettyInfo =
info
(pure Pretty)
(progDesc "Translate a MiniJuvix file to MicroJuvix and pretty print the result")
typeCheckInfo :: ParserInfo MicroJuvixCommand
typeCheckInfo =
info
(TypeCheck <$> parseMicroJuvixType)
(progDesc "Translate a MiniJuvix file to MicroJuvix and typecheck the result")
parseMicroJuvixType :: Parser MicroJuvixTypeOptions
parseMicroJuvixType = do
_microJuvixTypePrint <-
switch
( long "print-result"
<> help "Print the type checked module if successful"
)
pure MicroJuvixTypeOptions {..}