-
Notifications
You must be signed in to change notification settings - Fork 119
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
Opaque types? #870
Comments
I hesitate to even mention this because we are strongly considering removing this feature, but we actually have had for some time now an experimental
As we can see from #912, people do indeed want the ability to implement new instances :-) That would really be a major new language feature. |
After thinking about this a bit, I'm of the opinion that we ought to add |
I always liked the idea of having |
Erasing newtypes when translating to SAW should work for now. (Although at some point in the future it might be nice to make SAW preserve all Cryptol typing information, so we will probably want to revisit this later.) So I'm fine with making |
Newtypes are now fully supported with the merge of #1015. |
I sometimes stub my toe by applying one of the built-ins, typically
==
or+
, to something I shoudn't. The type-checker allows this because so many things satisfy Cmp (or is it Eq?) or Ring. So it would occasionally be convenient to have a type constructor that is not a member of these classes. For example, a constructoropaque
with an interface likeand where
opaque t
is in none of the type classes. It would be quite convenient if we also had the ability to write things likeThere is a sort of a way to fake this now, for example, with
This does indeed prevent the inadvertent application of a built-in. It is not really satisfactory, though, as it makes
opaque t
not a testable or provable type. For example, with typeopaque Bit
in Cryptol we find
So, having a built-in opaque type constructor would be a win here. To be sure this is just a mild suggestion, as the situation comes up infrequently, but it seems like an easy thing to add.
Of course if you do add this feature, someone would be sure to ask why we could not now define a way to add custom definitions for some class, for example, adding my own functions to be
==
and!=
for my opaque type.The text was updated successfully, but these errors were encountered: