-
Notifications
You must be signed in to change notification settings - Fork 643
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
Provide a smart aliasing feature #1518
Comments
I don’t think the injectivity thing is a problem is it? Since unification looks at the normal form of a value rather than the top level it will know ‘Pair’ is injective because ‘HVect’ is injective. Or have you found a situation where this doesn’t work? The pattern matching problem is different, though. I know some people have expected what you’re describing to work (e.g. defining one = S Z and expecting it to be possible to match on ‘one’, which doesn’t work because ‘one’ is bound as a pattern variable). Maybe instead of ‘alias’ we could mark a definition as a ‘pattern’ definition meaning that it should not be bound in a pattern clause. (Usual caveat that I haven’t thought this through yet, this is just my first thoughts on the suggestion...) On 9 Sep 2014, at 21:47, Ahmad Salim Al-Sibahi notifications@github.com wrote:
|
@edwinb Hmm, I thought there was once a time where I experienced such issue; but I cannot remember exactly why. It is perhaps not a problem, but maybe it could be nice to have a way to enforce such thing (like the total keyword)? I am not sure how pattern aliases should work yet, but I thought it might be a good idea to propose something. |
Something like this would be very nice, but there hasn't been any proposal on exactly how to make this work or what the feature would look like, and there doesn't seem to be anyone enthusiastic about working on it. I'm closing this, therefore, but any concrete proposals on this idea would still be welcome (perhaps better as a dragon egg) |
Currently it is possible to some aliasing by simply declaring a function with result type
Type
, likeHowever, such declaration loses injectivity which is that if Pair a b = Pair a' b' then a = a' and b = b' are not necessarily true. It would therefore be desirable to be able to define an injective alias akin to
A more advanced feature would be to provide constructor aliases, which can also be used for pattern matching.
Since overloading is usually possible in constructors, it would also be desirable to have overloading on aliases (and disambiguate by result type as usual), like overloading
Singleton
:While there is a way to define new pattern syntax, it doesn't work well with pattern matching, e.g.
is not nice to do with pattern syntax, especially with multiple different possible implicit arguments.
This request aims to make it easier to deprecate things by renaming, and provide ways to make more readable type signatures by simplifying complex types.
The text was updated successfully, but these errors were encountered: