[GHC] #9671: Allow expressions in patterns
GHC
ghc-devs at haskell.org
Fri Oct 10 19:22:09 UTC 2014
#9671: Allow expressions in patterns
-------------------------------------+-------------------------------------
Reporter: | Owner:
Iceland_jack | Status: new
Type: feature | Milestone: 7.10.1
request | Version:
Priority: normal | Keywords: patterns, pattern
Component: Compiler | synonyms
Resolution: | Architecture: Unknown/Multiple
Operating System: | Difficulty: Unknown
Unknown/Multiple | Blocked By:
Type of failure: | Related Tickets:
None/Unknown |
Test Case: |
Blocking: |
Differential Revisions: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Your examples all use constants, but I assume you are going to allow this:
{{{
f :: Person -> Map Person Age -> Age
f p (Lookup p a) = a
f p _ = error ("No info on " ++ show p)
}}}
Now this is jolly confusing. In the pattern `(Lookup p a)`, `p` is a
bound occurence while `a` is a binding occurrence.
This distinction is made syntactically by view patterns:
{{{
f :: Person -> Map Person Age -> Age
f p ((\m -> lookup m p) -> a) = a
}}}
Here the stuff on the left of the view-pattern arrow `->` are bound
occurrences, while the stuff on the right is binding.
You could even have
{{{
f p (Lookup p p) = p
}}}
meaning
{{{
f p1 (Lookup p1 p2) = p2
}}}
To me, the lack of syntactic cues for what is bound and what is binding
seems quite serious.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9671#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list