Changes between Version 1 and Version 2 of Design/RedundantConstraints


Ignore:
Timestamp:
Feb 16, 2016 12:34:09 PM (4 years ago)
Author:
Lemming
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Design/RedundantConstraints

    v1 v2  
    1 GHC-8.0 introduced `warn-redundant-constraints`.
    2 But what does it mean at all to have a redundant constraint?
    3 If you can remove a constraint and the function is still type-correct then you might call the constraint redundant.
    4 E.g. in
    5 {{{#!hs
    6 singleton :: (Ord a) => a -> Set a
    7 }}}
    8 the compiler should warn about the redundant `Ord a`.
    9 The programmer still might want that constraint in order to be more flexible at later internal refactorings.
    10 
    11 But what about this:
    12 {{{#!hs
    13 asTypeOf1 :: (a ~ b) => a -> b -> a
    14 asTypeOf1 x _ = x
    15 }}}
    16 ? `ghci-8.0.0.20160214 -fwarn-redundant-constraints` warns about the equality constraint.
    17 
    18 However, you might write it the Haskell 98 way:
    19 {{{#!hs
    20 asTypeOf :: a -> a -> a
    21 asTypeOf x _ = x
    22 }}}
    23 There is no constraint to complain about, but the function has not the most general type.
    24 Is this a redundant constraint, too?