[GHC] #8779: Exhaustiveness checks for pattern synonyms
GHC
ghc-devs at haskell.org
Fri Jan 6 18:48:51 UTC 2017
#8779: Exhaustiveness checks for pattern synonyms
-------------------------------------+-------------------------------------
Reporter: nomeata | Owner: mpickering
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 7.8.1
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:D2669
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by rwbarton):
I feel like my suggestion, whatever it was, must have been
misinterpreted... I'm concerned about situations in which there are no
view patterns, at all.
Take this scenario. I have a data type with a lot of `Either` fields
{{{#!hs
data T = T String (Either Int T) (Either Int T) (Either Int T) (Either Int
T)
}}}
and I need to write a bunch of functions like
{{{#!hs
f (T s (Left _) (Left _) (Left n) (Right _)) = replicate n s
f (T s (Left _) (Left n) (Right _) (Right _)) = replicate (n-1) s
-- ...
}}}
It sure would be handy if I could define
{{{#!hs
pattern L <- Left _
pattern R <- Right _
}}}
to condense the long left-hand sides. It just seems so obvious that I
should be able to use a ''pattern synonym'' as a shorthand for a pattern,
without having to go through extra contortions to appease the
exhaustiveness checker.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8779#comment:47>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list