[GHC] #9793: Some as-patterns could be accepted in pattern synonyms
GHC
ghc-devs at haskell.org
Mon Dec 21 09:33:53 UTC 2015
#9793: Some as-patterns could be accepted in pattern synonyms
-------------------------------------+-------------------------------------
Reporter: cactus | Owner: cactus
Type: feature request | Status: patch
Priority: normal | Milestone: 8.0.1
Component: Compiler (Type | Version: 7.8.3
checker) | Keywords:
Resolution: | PatternSynonyms
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s): Phab:D1666
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by simonpj):
Hang on. What is the ''design'' here? Specifically, what is the
semantics of matching?
To put it another way, suppose I have
{{{
pattern P x <- x@(Right _)
}}}
What does it mean to match against ''that''?
Well, to a first approximation, in a pattern, `P pat` means the same as
`<rhs of P> with pat instead of x`. So
{{{
f (P (Left y)) = e
}}}
means
{{{
f ((Left y)@(Right _)) = e
}}}
And what does ''that'' mean?
Perhaps we could expand the semantics of as-patterns to be `p1 @ p2`,
meaning match against ''both'' `p1` ''and'' `p1`. An "and-pattern" if you
like. Now everything would be well-specified. And I suppose you could say
things like
{{{
f ((\xs -> length xs < 10) -> True)@(y:_) = ...
}}}
which would match against a list of length shorter than 10, and then bind
'y' to the head of that list.
But this is a bigger change, and not directly related to pattern synonyms.
So far I'm unconvinced.
Simon
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9793#comment:5>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list