Skip to content
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

Allow more/generalize let/where pattern bindings. #357

Open
bergmark opened this issue Oct 25, 2013 · 5 comments
Open

Allow more/generalize let/where pattern bindings. #357

bergmark opened this issue Oct 25, 2013 · 5 comments

Comments

@bergmark
Copy link
Member

As reported in #310 these are examples of unsupported patterns:

where
  serverDate = year ++ "-" ++ month ++ "-" ++ day
  (month:day:year:[]) = split jqDate '/'
where
  pos :: (Int, Int, Int)
  pos@(x, y, z) = (1, 2, 3) -- This is the culprit.

... and more. The code is in Fay.Compiler.Decl.compilePatBind, the general case is pretty hacky and can be improved. Note that most if not all patterns are implemented for case statements already.

@osa1
Copy link
Contributor

osa1 commented Nov 29, 2013

@bergmark what's the status of this? I guess I could work on this.

I think in Haskell every pattern matching construct gets desugared into case expressions with one level of pattern matching. I think we can use similar thing and remove all pattern matching constructs except case expressions in desugaring phase.

@bergmark
Copy link
Member Author

@osa1 that sounds great!

No one is working on it so please go ahead :)

@bergmark
Copy link
Member Author

@osa1 Did you start working on this? I think it would simplify my typeclass branch a lot, so please let me know if you are working on it or if I should tackle it myself.

I would like every top level declaration to desugar into a single unguarded case:

f 1 = x
f y | p = z
=>
f w = case w of
  1 -> x
  y | p -> z

@osa1
Copy link
Contributor

osa1 commented Jan 13, 2014

Ahh, sorry @bergmark couldn't spare my time to work on this.

The algorithm should not be very hard and IIRC it's should be explained in The Implementation of Functional Programming Languages chapter 5.

@bergmark
Copy link
Member Author

Alright I'll take a look at that, thanks!

@ghost ghost assigned bergmark Jan 26, 2014
@bergmark bergmark removed their assignment Oct 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants