-
Notifications
You must be signed in to change notification settings - Fork 26
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
Pattern matching on Maybe <function> causes compilation error. #427
Comments
^ Copy pastable version for those of us who don't have that special vim mode. Note that the following program generates the same error so the Maybes don't actually have anything to do with how the error arises:
|
On line 840 in
The goal is to find the names of the new variables introduced by the pattern. To do that we are filtering out those with function type in order to get rid of the object patterns. If we remove the
Allthough that might be a good thing. What do you guys think? If this should compile then we'll have to write a new custom function to extract the free variables from the pattern. If we don't want it to compile then we'll have to add some extra error checking to the typechecker. |
Presumably it is the last line you are referring to. That looks evil, though I cannot formula a good reason why it is evil. |
I agree with @supercooldave. In this case it looks extremely odd. My brain does not parse that. I think the weirdness of this comes from the implicit assumption that the expression I'm very confused. |
The fact that the program uses extractor methods makes the program look odd, if you don't know about extractor methods (if that's what they are called). But that's not what I find weird. It's the use of a 'global' name |
The program is the same as this one, except some wierdo used
And then the question turns into whether this should compile or not:
And yes they're called extractors in Scala. Though I've been promoting the name object patterns since extractors is Scala specific and the idea really is both older and more widespread than Scala, though Scala definitely is the largest language by far which includes them. |
Object Patterns is a nicer name. |
No no no. the last one should not compile IMO. Having the And if this is the trade-of we need to do to have pattern matching on functions it is totally worth it. |
It should not compile. |
No Henrik, we can have matching on functions either way. Its just that the way we get it differs depending on whether that code example should compile or not. I asked Elias about it and he was of the mind that |
Compiling the following program:
produces this compiler error (with the
-v
flag):The text was updated successfully, but these errors were encountered: