Export Unit's constructor for use in pattern matches.#57
Conversation
|
Seems my build is failing, embarrassingly, with: I don't believe this is related to my patch though? |
|
See #56. Amending and pushing should trigger Travis again. |
|
I think I've seen lots of FFI code that simply returns undefined for Unit values. Could pattern matching like this cause problems in these cases? |
|
I think the pattern match would actually be written \x y z Unit -> ...which shouldn't cause problems based on unit's value. |
|
That doesn't work though right? Since |
|
Yeah, @lunaris is right; Unit is currently |
|
Ultimately this was my hope all along, but I figured this was the smallest possible PR and didn't want to talk about the bikeshed's colour at the same time as proposing we leave the door open 😄 |
|
Changing the declaration to that probably will stop pattern matching from working for ☔ |
|
So if we say that we leave it as it is, and say that you have to use |
|
Type annotations won't affect code gen of binders. I think the point is that if you match the |
|
I think the way to remedy this is to just say |
|
I'm guessing this PR should be closed then? Though, if I understand things correctly, given you're striving not to have a "built-in" Prelude, does it need to be documented that any Prelude users provide themselves has a constraint that |
|
I don't think we would need that, because all the |
|
My mistake; I only got this impression because the Prelude isn't imported by default. Shall I close this then? |
I think it's helpful to be able to pattern match on values of type
Unit(even if we always know what they are) in order to guide type inference in cases such as:The alternative is having to write
(_ :: Unit). This is admittedly only slightly longer, but I don't find the use of a type annotation very natural here. I'd be interested to hear your thoughts.