[GHC] #3927: Incomplete/overlapped pattern warnings + GADTs = inadequate

GHC ghc-devs at haskell.org
Wed Dec 10 20:12:26 UTC 2014


#3927: Incomplete/overlapped pattern warnings + GADTs = inadequate
-------------------------------------+-------------------------------------
              Reporter:  simonpj     |            Owner:  simonpj
                  Type:  bug         |           Status:  new
              Priority:  normal      |        Milestone:  7.10.1
             Component:  Compiler    |          Version:  6.12.1
            Resolution:              |         Keywords:
      Operating System:              |     Architecture:  Unknown/Multiple
  Unknown/Multiple                   |       Difficulty:  Unknown
       Type of failure:              |       Blocked By:
  None/Unknown                       |  Related Tickets:  #4139
             Test Case:              |
              Blocking:              |
Differential Revisions:              |
-------------------------------------+-------------------------------------

Comment (by vlopez):

 Instead of fixing the exhaustiveness checker, we could have some way to
 tell the compiler that a particular branch in a case expression (or
 function definition) is inaccessible.

 A possible syntax for this would be an "empty guard" (a vertical bar
 immediately followed by a semicolon).

 {{{
 data T a where
   T1 :: T Int
   T2 :: T Bool

 f1 :: T a -> T a -> Bool
 f1 T1 T1 = True
 f1 T2 T2 = False
 f1 T1 T2 |; -- absurd branch
 f1 T2 T1 |; -- another absurd branch

 f2 :: T a -> T a -> Bool
 f2 a b = case (a,b) of
     (T1, T1) -> True
     (T2, T2) -> False
     (T1, T2) |;
     (T2, T1) |;
 }}}

 * In GHC 7.8.3, it results in an immediate parser error at the `;`, so it
 shouldn't conflict with other features.
 * It works well with the indentation heuristics in emacs haskell-mode (and
 hopefully with other editors too).

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


More information about the ghc-tickets mailing list