Skip to content

Commit

Permalink
Make tests happy
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaprieto committed Apr 5, 2023
1 parent 421b74f commit 93ca892
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 15 deletions.
6 changes: 3 additions & 3 deletions app/Commands/Compile/Options.hs
Expand Up @@ -11,8 +11,8 @@ import Data.List.NonEmpty qualified as NonEmpty
supportedTargets :: NonEmpty CompileTarget
supportedTargets = NonEmpty.fromList allTargets

parseUserCompileOptions :: Parser CompileOptions
parseUserCompileOptions =
parseMainCompileOptions :: Parser CompileOptions
parseMainCompileOptions =
parseCompileOptions
supportedTargets
parseInputJuvixAsmFile
parseInputJuvixFile
9 changes: 4 additions & 5 deletions app/Commands/Dev/Asm/Compile/Options.hs
Expand Up @@ -13,11 +13,10 @@ type AsmCompileOptions = CompileOptions
asmSupportedTargets :: NonEmpty CompileTarget
asmSupportedTargets =
NonEmpty.fromList
( [ TargetWasm32Wasi,
TargetNative64,
TargetAsm
]
)
[ TargetWasm32Wasi,
TargetNative64
]


parseAsmCompileOptions :: Parser AsmCompileOptions
parseAsmCompileOptions =
Expand Down
17 changes: 16 additions & 1 deletion app/Commands/Dev/Runtime/Options.hs
Expand Up @@ -2,11 +2,26 @@ module Commands.Dev.Runtime.Options where

import Commands.Dev.Runtime.Compile.Options
import CommonOptions
import Data.List.NonEmpty qualified as NonEmpty

newtype RuntimeCommand
= Compile CompileOptions
deriving stock (Data)

runtimeSupportedTargets :: NonEmpty CompileTarget
runtimeSupportedTargets =
NonEmpty.fromList
[ TargetWasm32Wasi,
TargetNative64
]

parseRuntimeOptions :: Parser CompileOptions
parseRuntimeOptions =
parseCompileOptions
runtimeSupportedTargets
parseInputJuvixFile


parseRuntimeCommand :: Parser RuntimeCommand
parseRuntimeCommand =
hsubparser $
Expand All @@ -20,5 +35,5 @@ parseRuntimeCommand =
compileInfo :: ParserInfo RuntimeCommand
compileInfo =
info
(Compile <$> parseCompileOptions parseInputCFile)
(Compile <$> parseRuntimeOptions)
(progDesc "Compile a C file with Juvix runtime included")
9 changes: 6 additions & 3 deletions app/Commands/Extra/Compile/Options.hs
Expand Up @@ -87,15 +87,18 @@ optCompileTarget supportedTargets =
<> metavar "TARGET"
<> value TargetNative64
<> showDefault
<> help ("select a target: " <> show supportedTargets)
<> completeWith (map show (toList supportedTargets))
<> help ("select a target: " <> show listTargets)
<> completeWith (map show listTargets)
)
where
listTargets :: [CompileTarget]
listTargets = toList supportedTargets

parseTarget :: String -> Either String CompileTarget
parseTarget txt =
maybe err return $
lookup
(map toLower txt)
[(Prelude.show t, t) | t <- toList supportedTargets]
[(Prelude.show t, t) | t <- listTargets]
where
err = Left $ "unrecognised target: " <> txt
2 changes: 1 addition & 1 deletion app/TopCommand/Options.hs
Expand Up @@ -144,7 +144,7 @@ commandCompile :: Mod CommandFields TopCommand
commandCompile =
command "compile" $
info
(Compile <$> parseUserCompileOptions)
(Compile <$> parseMainCompileOptions)
(progDesc "Compile a Juvix file")

commandEval :: Mod CommandFields TopCommand
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/language/modules.md
Expand Up @@ -15,7 +15,7 @@ end;
A <u>Juvix project</u> is a collection of Juvix modules inside one main
project folder containing a metadata file named `juvix.yaml`. Each Juvix
file has to define a <u>module</u> of the same name. The name of the
module must coincide with the path of the its file relative to its
module must coincide with the path of its file relative to its
project's root directory. For example, if the file is
`root/Data/List.juvix` then the module must be called `Data.List`,
assuming `root` is the project's folder.
Expand Down Expand Up @@ -115,7 +115,7 @@ We simplify it by the expression:
open import Prelude;
```

The `hiding` keyword can be used within an `open-import` statement.
The `hiding` keyword can be used within a `open-import` statement.

```juvix
-- B.juvix
Expand Down

0 comments on commit 93ca892

Please sign in to comment.