-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is similar to `juvix dev nockma run`. The difference is that the mamaged client is used and it outputs the result as a jammed file.
- Loading branch information
1 parent
669474f
commit 5c3449b
Showing
10 changed files
with
142 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Commands.Dev.Anoma.Base where | ||
|
||
import Anoma.Effect | ||
import Commands.Base hiding (Atom) | ||
import Juvix.Compiler.Nockma.Pretty | ||
import Juvix.Compiler.Nockma.Translation.FromSource qualified as Nockma | ||
|
||
-- | Calls Anoma.Protobuf.NockService.Prove | ||
runNock :: forall r. (Members '[Error SimpleError, Anoma] r, Members AppEffects r) => AppPath File -> Maybe (AppPath File) -> Sem r RunNockmaResult | ||
runNock programFile margsFile = do | ||
afile <- fromAppPathFile programFile | ||
argsFile <- mapM fromAppPathFile margsFile | ||
parsedArgs <- runAppError @JuvixError (mapM Nockma.cueJammedFileOrPretty argsFile) | ||
parsedTerm <- runAppError @JuvixError (Nockma.cueJammedFileOrPretty afile) | ||
case parsedTerm of | ||
TermAtom {} -> exitFailMsg "Expected nockma input to be a cell" | ||
t@(TermCell {}) -> go t (maybe [] unfoldList parsedArgs) | ||
where | ||
go :: Term Natural -> [Term Natural] -> Sem r RunNockmaResult | ||
go t args = | ||
runNockma | ||
RunNockmaInput | ||
{ _runNockmaProgram = t, | ||
_runNockmaArgs = args | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Commands.Dev.Anoma.Prove where | ||
|
||
import Anoma.Effect.Base | ||
import Anoma.Effect.RunNockma | ||
import Commands.Base | ||
import Commands.Dev.Anoma.Base | ||
import Commands.Dev.Anoma.Prove.Options | ||
import Juvix.Compiler.Nockma.Encoding.Jam qualified as Encoding | ||
import Juvix.Compiler.Nockma.Pretty hiding (Path) | ||
|
||
runCommand :: forall r. (Members (Anoma ': Error SimpleError ': AppEffects) r) => ProveOptions -> Sem r () | ||
runCommand opts = do | ||
res <- runNock (opts ^. proveFile) (opts ^. proveArgs) | ||
let traces = res ^. runNockmaTraces | ||
forM_ traces (renderStdOutLn . ppPrint) | ||
let provedCode = Encoding.jamToByteString (res ^. runNockmaResult) | ||
outputFile <- getOutputFile (opts ^. proveOutputFile) | ||
writeFileBS outputFile provedCode | ||
where | ||
getOutputFile :: (Member App x) => Maybe (AppPath File) -> Sem x (Path Abs File) | ||
getOutputFile = \case | ||
Just out -> fromAppFile out | ||
Nothing -> do | ||
invokeDir <- askInvokeDir | ||
programFilePath <- fromAppFile (opts ^. proveFile) | ||
let baseOutputFile = invokeDir <//> filename programFilePath | ||
return (replaceExtensions' (".proved" :| [".nockma"]) baseOutputFile) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module Commands.Dev.Anoma.Prove.Options where | ||
|
||
import CommonOptions | ||
|
||
data ProveOptions = ProveOptions | ||
{ _proveFile :: AppPath File, | ||
_proveArgs :: Maybe (AppPath File), | ||
_proveClientInfo :: Maybe (AppPath File), | ||
_proveOutputFile :: Maybe (AppPath File) | ||
} | ||
deriving stock (Data) | ||
|
||
makeLenses ''ProveOptions | ||
|
||
parseProveOptions :: Parser ProveOptions | ||
parseProveOptions = do | ||
_proveFile <- parseInputFile FileExtNockma | ||
_proveArgs <- optional anomaArgsOpt | ||
_proveClientInfo <- optional anomaClientConfigOpt | ||
_proveOutputFile <- optional parseGenericOutputFile | ||
pure ProveOptions {..} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters