[GHC] #8779: Exhaustiveness checks for pattern synonyms

GHC ghc-devs at haskell.org
Sat May 21 02:04:46 UTC 2016


#8779: Exhaustiveness checks for pattern synonyms
-------------------------------------+-------------------------------------
        Reporter:  nomeata           |                Owner:
            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):
       Wiki Page:                    |
-------------------------------------+-------------------------------------

Comment (by Iceland_jack):

 Replying to [comment:23 dfeuer]:
 > Yes, sometimes, but when pattern synonyms overlap (e.g., left and right
 views, with empty), life sucks again.

 `MINIMAL` pragmas allow conjunction as well as disjunction

 {{{#!hs
 {-# MINIMAL fromRational, (recip | (/)) #-}
 }}}

 If you want to express that `Empty` and `(:<|)` form a complete pattern
 but so does `Empty` and `(:|>)`

 {{{#!hs
 pattern Empty :: Seq.Seq a
 pattern Empty <- (Seq.viewl -> Seq.EmptyL)
   where Empty = Seq.empty

 pattern (:<|) :: a -> Seq.Seq a -> Seq.Seq a
 pattern x :<| xs <- (Seq.viewl -> x Seq.:< xs)
   where x :<| xs = x Seq.<| xs

 pattern (:|>) :: Seq.Seq a -> a -> Seq.Seq a
 pattern xs :|> x <- (Seq.viewr -> xs Seq.:> x)
   where xs :|> x = xs Seq.|> x
 }}}

 so what's stopping us from writing

 {{{#!hs
 {-# COMPLETE_PATTERNS (Empty, (:<|)) | (Empty, (:|>)) #-}
 }}}

 to mean just that?

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8779#comment:24>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list