You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Types module is repeated in many places, which makes refactor quite hard to perform. In order to refactor this, let's understand where it is used and how it differs in different places:
The first one is in types.ml:
module type Types=sigmoduleChecked : sigtype('a, 'f) tendmoduleAs_prover : sigtype('a, 'f) tendmoduleTyp : sigincludemoduletype of Typ.Ttype('var, 'value, 'f) t = ('var, 'value, 'f, (unit, 'f) Checked.t) Typ.tendmoduleProvider : sigincludemoduletype of Provider.Ttype('a, 'f) t =
(('aRequest.t, 'f) As_prover.t, ('a, 'f) As_prover.t) providerendend
Note: it seems like we can safely remove the As_prover one. See #750
which references other types from the same file/module.
Other occurrences:
~ As_prover.S.Types | same as Types.Types
~ As_prover.Extended.Types | sames as Types.Types
x As_prover.Make (Checked) (_): S | creates it from Checked.Types
x As_prover.Make_extended (Checked) (_): S | creates it from Checked.Types
x As_prover.T.Types and As_prover.Types | creates it from Checked_ast.Types
x Checked_ast.Types (where Checked0 is the AST):
moduleTypes=structmoduleChecked=structtype('a, 'f) t = ('a, 'f) Checked0.tendmoduleAs_prover=structtype('a, 'f) t = ('a, 'f) As_prover0.tendmoduleTyp=structincludeTypes.Typ.Ttype('var, 'value, 'f) t = ('var, 'value, 'f, (unit, 'f) Checked.t) typendmoduleProvider=structincludeTypes.Provider.Ttype('a, 'f) t =
(('aRequest.t, 'f) As_prover0.t, ('a, 'f) As_prover0.t) providerendend
x Checked_ast.Basic.Types | uses Checked_ast.Types
~ Checked_intf.Basic.Types | uses Types.Types
~ Checked_intf.S.Types | uses Types.Types
~ Checked_intf.Extended.Types | uses Types.Types
x Checked_runner.Simple.Types
moduleTypes=structmoduleChecked=structtype('a, 'f) t =
| Pureof'a
| Functionof ('fRun_state.t -> 'fRun_state.t*'a)
endmoduleAs_prover=structtype('a, 'f) t = ('a, 'f) As_prover.tendmoduleTyp=structincludeTypes.Typ.Ttype('var, 'value, 'f) t = ('var, 'value, 'f, (unit, 'f) Checked.t) typendmoduleProvider=structincludeTypes.Provider.Ttype('a, 'f) t =
(('aRequest.t, 'f) As_prover.t, ('a, 'f) As_prover.t) providerendend
x Checked_runner.Make_checked
moduleTypes=structmoduleChecked=structtype('a, 'f) t = ('a, Backend.Field.t) Simple.Types.Checked.tendmoduleAs_prover=structtype('a, 'f) t = ('a, 'f) As_prover.tendmoduleTyp=structincludeTypes.Typ.Ttype('var, 'value, 'f) t = ('var, 'value, 'f, (unit, 'f) Checked.t) typendmoduleProvider=structincludeTypes.Provider.Ttype('a, 'f) t =
(('aRequest.t, 'f) As_prover.t, ('a, 'f) As_prover.t) providerendend
~ Checked_runner.Run_extras | uses Types.Types
x Checked_runner.Make (_) | creates Types from Checked_ast.Types
What I'm able to infer from this is that Types.Types defines Checked.t as abstract, and the other types are based on that. Then they can be instantiated by the different monads:
Checked_ast uses its own Checked.t (the AST monad)
Checked_runner uses its own Checked.t as well (the state monad)
The question I am trying to answer is the following:
what's the pattern here? Why are we creating or passing this Types module everywhere? Especially as this module is eventually removed from the snark interface (does not appear in snark_intf.ml)
why is Checked_runner.Make still relying on Checked_ast.Types -> this one is easy, we can simply use Checked.Types
why is As_prover.T.Types and As_prover.Types still relying on the Checked_ast Types
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
A
Types
module is repeated in many places, which makes refactor quite hard to perform. In order to refactor this, let's understand where it is used and how it differs in different places:The first one is in
types.ml
:which references other types from the same file/module.
Other occurrences:
What I'm able to infer from this is that
Types.Types
definesChecked.t
as abstract, and the other types are based on that. Then they can be instantiated by the different monads:Checked_ast
uses its ownChecked.t
(the AST monad)Checked_runner
uses its ownChecked.t
as well (the state monad)The question I am trying to answer is the following:
Types
module everywhere? Especially as this module is eventually removed from the snark interface (does not appear insnark_intf.ml
)Checked_runner.Make
still relying onChecked_ast.Types
-> this one is easy, we can simply useChecked.Types
As_prover.T.Types
andAs_prover.Types
still relying on the Checked_astTypes
Beta Was this translation helpful? Give feedback.
All reactions