[GHC] #11390: GHC does not warn about redundant patterns

GHC ghc-devs at haskell.org
Sat Jan 9 16:54:59 UTC 2016


#11390: GHC does not warn about redundant patterns
-------------------------------------+-------------------------------------
        Reporter:  Iceland_jack      |                Owner:
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.1
      Resolution:                    |             Keywords:  warnings
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by Iceland_jack:

Old description:

> Given the Phab:D1535 effort in GHC 8.0 I was curious how an example from
> Richard's post [https://typesandkinds.wordpress.com/2015/09/09/what-are-
> type-families/ What are type families?] would fare:
>
> {{{
> % ghci -Wall -XTypeFamilies -ignore-dot-ghci
> GHCi, version 8.1.20160105: http://www.haskell.org/ghc/  :? for help
> Prelude> :set +m
> Prelude> type family F1 a where
> Prelude|   F1 Int = Bool
> Prelude|
> Prelude> let
> Prelude|   sillyId :: F1 Char -> F1 Char
> Prelude|   sillyId x = x
> Prelude|
> Prelude>
> }}}
>
> This seems to fly, even though as the blog post noted, ”[...] sillyId
> can’t ever be called on a value.” Isn't the clause redundant and should
> be defined using `EmptyCase` (#2431) as `sillyId x = case x of {}`?
>
> It seems GHC doesn't care that the pattern match in the equation `absurd2
> _ = ...` is redundant either:
> {{{#!hs
> data Void
>
> absurd1 :: Void -> a;
> absurd1 = \case
>
> absurd2 :: Void -> a
> absurd2 _ = undefined
> }}}
>
> Is this intended or known behaviour?

New description:

 Given the Phab:D1535 effort in GHC 8.0 I was curious how an example from
 Richard's post [https://typesandkinds.wordpress.com/2015/09/09/what-are-
 type-families/ What are type families?] would fare:

 {{{
 % ghci -Wall -XTypeFamilies -ignore-dot-ghci
 GHCi, version 8.1.20160105: http://www.haskell.org/ghc/  :? for help
 Prelude> :set +m
 Prelude> type family F1 a where
 Prelude|   F1 Int = Bool
 Prelude|
 Prelude> let
 Prelude|   sillyId :: F1 Char -> F1 Char
 Prelude|   sillyId x = x
 Prelude|
 Prelude>
 }}}

 This seems to fly, even though as the blog post noted, ”[...] sillyId
 can’t ever be called on a value.” Isn't the clause redundant and should be
 defined using `EmptyCase` (#2431) as `sillyId x = case x of {}`?

 It seems GHC doesn't care that the pattern match in the equation `absurd2
 _ = ...` is redundant either:
 {{{#!hs
 data Void

 absurd1 :: Void -> a
 absurd1 = \case

 absurd2 :: Void -> a
 absurd2 _ = undefined
 }}}

 Is this intended or known behaviour?

--

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


More information about the ghc-tickets mailing list