-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(lltz michelson): tests added #26
base: main
Are you sure you want to change the base?
Conversation
9551076
to
74ff885
Compare
I have a general question. The optional parameter |
I was thinking about keeping it as is, because I'm not sure how could it be solved otherwse. It seems to me that the DSL looks reasonably good with one unlabelled param and all other labelled - e.g. let_in (var) ~rhs:...~in_.... For e.g. unit () and similar, it could be improved and i agree that it would be better without having to add the brackets, however having the optional range parameter seems more important at this point. |
I guess my question then boils down to: Do you need the optional parameter in the long term? |
well the optional parameter was suggested by Alistair I assume primarily for possibility to add better testing of the DSL. Furthermore sometimes, DSL could be used for easier compilation in some cases (e.g. writing more complex code first in DSL, then compiling). So, I imagine it won't have very significant use cases, but it's nice to have so that if I decide to use it I don't have to restructure the DSL again. |
My experience with LIGO is that injecting dummies for source location is a temptation that regularly led to error messages without source locations. Like exceptions, they are convenient but often make us look bad. If we use a default parameter with a dummy, all it takes is to forget to pass a location and we have this issue. I'd rather have a normal version of the instruction set with mandatory locations (ranges) and a specialised version for testing only, with partial evaluation of those to dummies. Now, to rephrase my issue with the current design (with optionals): we have a fairly large instruction set, so we need a fairly uniform calling convention. For example, you changed
to
I think it would be much better to have
This way, we always have an optional parameter followed by one mandatory parameter (here, a record, which, conceptually, is a series of labelled parameters). We don't need partial application here anyway. Then
becomes uniform. |
74ff885
to
5052ce5
Compare
We resolved the linker issues with Alistair. Regarding the arguments, I think it quite complicates the usage of it - e.g. add x y, will become add {lhs=x, rhs=y} which doesn't look very good. Let in is not a very good example as in a further PR I will change it to a let* syntax, something like - let ( let* ) rhs in_ = let xname = Name.create () in let_ xname rhs ~in_:in_ as suggested by Alistair. I will add @johnyob to this discussion as he was imagining it slightly differently. |
5052ce5
to
81f2cc9
Compare
But it's the same as having labels, like so: Let's wait and see what Alistair has to say about this. |
I'd be opposed against having a record for each smart constructor. I propose we stick to labelled arguments (using unlabelled arguments only when the context is clear e.g. a single argument or lhs/rhs precedence) To solve the (* ast_builder.mli *)
module type Range = sig
val v : Range.t
end
module Dummy_range : Range
module type S = sig
type 'a with_range
val let_ : (pattern -> expr -> in_:expr -> expr) with_range
...
end
module Default : S with type 'a with_range := range:Range.t -> 'a
module Make (R : Range) : S with type 'a with_range := 'a
include Default
module With_dummy = Make (Dummy_range) |
@@ -62,6 +62,7 @@ | |||
); | |||
in { | |||
packages.default = opamPackages.lltz; | |||
packages.zarith = opamPackages.zarith; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be merged (added for debugging purposes)
"Assert_failure lib/lltz_michelson/type.ml:15:20" | ||
Raised at Lltz_michelson__Type.ors.loop in file "lib/lltz_michelson/type.ml", line 15, characters 20-32 | ||
Called from Lltz_michelson.compile_inj in file "lib/lltz_michelson/lltz_michelson.ml", line 508, characters 19-76 | ||
Called from Lltz_michelson.compile in file "lib/lltz_michelson/lltz_michelson.ml", line 249, characters 29-50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix asserts
Context
https://app.asana.com/0/1207308081067689/1208120654364721
Description
This PR adds inline tests testing execution of each instruction. The purpose is to be able to see the output of each instruction and see what changes if any further PRs make. It additionally change the form of DSL into a more readable format.
Manual testing