mirror of
https://github.com/anoma/juvix.git
synced 2024-12-20 13:21:47 +03:00
39 lines
1.1 KiB
Haskell
39 lines
1.1 KiB
Haskell
module Commands.Dev.Core.Read.Options where
|
|
|
|
import CommonOptions
|
|
import Juvix.Compiler.Core.Data.TransformationId.Parser
|
|
import Juvix.Compiler.Core.Pretty.Options qualified as Core
|
|
|
|
data CoreReadOptions = CoreReadOptions
|
|
{ _coreReadTransformations :: [TransformationId],
|
|
_coreReadShowDeBruijn :: Bool,
|
|
_coreReadInputFile :: Path
|
|
}
|
|
deriving stock (Data)
|
|
|
|
makeLenses ''CoreReadOptions
|
|
|
|
instance CanonicalProjection CoreReadOptions Core.Options where
|
|
project c =
|
|
Core.defaultOptions
|
|
{ Core._optShowDeBruijnIndices = c ^. coreReadShowDeBruijn
|
|
}
|
|
|
|
parseCoreReadOptions :: Parser CoreReadOptions
|
|
parseCoreReadOptions = do
|
|
_coreReadShowDeBruijn <- optDeBruijn
|
|
_coreReadTransformations <-
|
|
option
|
|
(eitherReader parseTransf)
|
|
( long "transforms"
|
|
<> short 't'
|
|
<> value mempty
|
|
<> metavar "[Transform]"
|
|
<> help "comma sep list of transformations. Available: lifting"
|
|
)
|
|
_coreReadInputFile <- parseInputJuvixFile
|
|
pure CoreReadOptions {..}
|
|
where
|
|
parseTransf :: String -> Either String [TransformationId]
|
|
parseTransf = mapLeft unpack . parseTransformations . pack
|