-
Notifications
You must be signed in to change notification settings - Fork 126
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
Constraint Integral ([n]a)
should imply a = Bit
#760
Comments
This requires closed world assumptions about the class instances, which is pretty different from how I usually think about class inference. Do we do inference of this sort elsewhere in Cryptol already? |
This seems similar to #265. Maybe there are reasons to infer such a general type, but it doesn't seem very user-friendly to me. |
I don't think this actually requires a closed-world assumption. We just need to have a single |
Well, I guess that's true, you don't have any confluence, etc. issues if you phrase the instance that way. However, I don't think we have a type equality constraint, even internally. It seems like it might be a pretty big change to add one. |
We have equality on numeric types, and it wouldn't be hard to add it to value types too. It's not there because (1) we didn't really need it in the past, and (2) it allows you to write odd type schemes like:
which complicates typechecking. My vote would be to add an equality predicate on value types, but to treat it as a bit of a 2nd class citizen, in that it should never end up in type schemes. In particular, users shouldn't be allowed to write them, and they should never end up in type schemes (i.e., trying to unify bound variables of kind |
Adding type equalities to the class system is probably too big of a change to be worth it just for this feature. |
Cryptol infers what I consider to be a too-general type for expressions involving shift/indexing operators:
I would expect that the constraint
Integral ([n]a)
should improve to the type equalitya = Bool
, and then be discharged.The text was updated successfully, but these errors were encountered: