Replies: 2 comments 1 reply
-
We shouldn't need to do anything. Consider the monad type type ('a, 'f) t = 'f Run_state.t -> 'a * Run_state.t
let return x : _ t = fun _run_state -> x
let map (x : _ t) ~f = fun run_state ->
let x, run_state = x run_state in
f x, run_state
let bind (x : _ t) ~f = fun run_state ->
let x, run_state = x run_state in
let y, run_state = f x run_state in
y, run_state Then val add_constraint : ('f field Cvar.t, 'f field) Constraint.t -> 'f field Run_state.t -> unit * 'f field Run_state.t which already matches what will be required by the |
Beta Was this translation helpful? Give feedback.
-
A, probably somewhat flawed, picture of the current state: |
Beta Was this translation helpful? Give feedback.
-
In the work of reimplementing parts of snarky in Rust, we want to ideally maintain compatibility with the current usage of snarky in the Mina codebase. There's currently two APIs for snarky: a monadic one, and an imperative one. Both are used in Mina. The imperative one is currently built on top of the monadic one.
We are planning to write snarky-rs as an imperative API, as such we need to either get rid of the monadic API, or make the monadic API a wrapper around the imperative API (invert the current relationship between the two APIs).
The monadic interface is created from a module following the
Checked_intf.Basic
interface. If we can make that interface generic enough, so that it can contain an implementation of an imperative API, we'll successfully revert the APIs.Where is snarky used?
examples:
as you can see, lots of usage of the monadic API (
let%bind ...
)Changes necessary to invert the APIs
The current
Checked_intf.Basic
interface has functions like this:Eventually we will have
t
here be a runstate used in an imperative implementation (and not an AST like in the monadic implementation). So we'll have to change these kind of signatures to:unless we use a global, in which case
t
will contain nothing? I'm not super clear on what the path forward is there.Removing dependency on the Checked_ast module in Typ
One of the steps to get there is to make the
Typ
module generic over aChecked
interface. Currently it is not, as can be seen in insnark_intf.ml
it still relies onChecked_ast.t
:Beta Was this translation helpful? Give feedback.
All reactions