-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds support for Anoma/Nockma scry OP. It is used for obtaining values from the Anoma storage (key value store). See the [linked issue](#2672) for details on scry. This PR adds support for scry to the Nockma language and compilation from the frontend via a builtin: `anoma-get`: ``` builtin anoma-get axiom anomaGet : {Value Key : Type} -> Key -> Value ``` In the backend, the `Value` and `Key` types could be anything, they will depend on choices of Anoma applications. The type of the returned `Value` is unchecked. It's currently the responsibility of the user to match the annotated type with the type of data in storage. We will not put this builtin in the standard library. It will be exposed in the anoma-juvix library. It's likely that the frontend `anomaGet` function will evolve as we use it to write Anoma applications and learn how they work. * Closes #2672 --------- Co-authored-by: Jan Mas Rovira <janmasrovira@gmail.com>
- Loading branch information
1 parent
3a4cbc7
commit 2e00642
Showing
41 changed files
with
334 additions
and
25 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
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,19 @@ | ||
module Juvix.Compiler.Builtins.Anoma where | ||
|
||
import Data.HashSet qualified as HashSet | ||
import Juvix.Compiler.Builtins.Effect | ||
import Juvix.Compiler.Internal.Extra | ||
import Juvix.Prelude | ||
|
||
registerAnomaGet :: (Members '[Builtins, NameIdGen] r) => AxiomDef -> Sem r () | ||
registerAnomaGet f = do | ||
let ftype = f ^. axiomType | ||
u = ExpressionUniverse smallUniverseNoLoc | ||
l = getLoc f | ||
keyT <- freshVar l "keyT" | ||
valueT <- freshVar l "valueT" | ||
let freeVars = HashSet.fromList [keyT, valueT] | ||
unless | ||
((ftype ==% (u <>--> u <>--> keyT --> valueT)) freeVars) | ||
(error "anomaGet must be of type {Value Key : Type} -> Key -> Value") | ||
registerBuiltin BuiltinAnomaGet (f ^. axiomName) |
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
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
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
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
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,12 @@ | ||
module Juvix.Compiler.Nockma.Evaluator.Storage where | ||
|
||
import Juvix.Compiler.Nockma.Language | ||
import Juvix.Prelude.Base | ||
|
||
newtype Storage a = Storage | ||
{_storageKeyValueData :: HashMap (Term a) (Term a)} | ||
|
||
emptyStorage :: (Hashable a) => Storage a | ||
emptyStorage = Storage {_storageKeyValueData = mempty} | ||
|
||
makeLenses ''Storage |
Oops, something went wrong.