summaryrefslogtreecommitdiff
path: root/testsuite/tests/warnings/should_compile/T19296.hs
blob: ef4ed74bcec6154586e8867cef4224c5bb88e361 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{-# OPTIONS_GHC -Wredundant-constraints -dsuppress-uniques #-}
{-# LANGUAGE DefaultSignatures, InstanceSigs #-}
module M ( f ) where

-- Redundant constraint
f :: Eq a => a -> ()
f _ = ()

-- Redundant constraint in expression signature
g _ = (\x -> ()) :: Eq a => a -> ()

-- GHC highlights more than necessary
h :: (Eq a, Ord b) => a -> b -> b
h _ b
    | b <= b = b
    | otherwise = b

-- Redundant constraint in specialize pragma.
-- Also generates an unrelated warning:
-- > Forall'd constraint ‘Eq a’ is not bound in RULE lhs
{-# SPECIALISE spec :: Eq a => a -> Int -> Int #-}

spec :: Ord b => a -> b -> b
spec _ b
    | b <= b = b
    | otherwise = b

class Foo a where
    foo :: [a]
    -- Redundant constraint in default method
    default foo :: Show a => [a]
    foo = []

class Bar a where
    bar :: Ord b => a -> b -> a

instance Bar Int where
    -- Redundant Constraint in Instance Signature
    bar :: (Eq b, Ord b) => Int -> b -> Int
    bar n _ = n