[GHC] #14112: bang patterns on pattern synonyms? (left vs right hand sides)
GHC
ghc-devs at haskell.org
Mon Aug 28 13:19:50 UTC 2017
#14112: bang patterns on pattern synonyms? (left vs right hand sides)
-------------------------------------+-------------------------------------
Reporter: carter | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.2.1
Resolution: | Keywords:
| PatternSynonyms
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by RyanGlScott):
Actually, I want to take back my proposal in comment:3. My idea relies on
the ability to put "bang patterns" on variable binders, which is something
that simply isn't possible anywhere else. (We could change the pattern
variable binders to be proper patterns and only allow them to be variables
or variables adorned with bangs, but that would be an exceedingly strange
design.)
In light of this, I would suggest that we endorse explicitly bidirectional
pattern synonyms as the only way to achieve a "two-way" strict pattern
synonym. That is:
{{{#!hs
pattern MyPair1 x y <- MkPair !x !y where
MyPair1 !x !y = MkPair x y
}}}
Therefore, the fact that you can currently do this:
{{{#!hs
pattern MyJust a = JustC !a
}}}
Should be treated as a bug. `JustC !a` makes no sense as an expression,
and moreover, it doesn't even give the strictness behavior that you'd
expect, as discovered in comment:2.
Does that sound agreeable, carter?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14112#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list