summaryrefslogtreecommitdiff
path: root/testsuite/tests/typecheck/should_compile/tc237.hs
blob: 00dc056940153ed62c915e0130c2103c0ccd0d64 (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
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
{-# LANGUAGE RankNTypes, MultiParamTypeClasses, FunctionalDependencies #-}

-- This one caught a bug in the implementation of functional
-- dependencies, where improvement must happen when
-- checking the call in 'test4'

module ShouldCompile where

newtype M s a = M a

class Modular s a | s -> a

wim ::  forall a w. Integral a
                      => a -> (forall s. Modular s a => M s w) -> w
wim i k = error "urk"

test4'  ::  (Modular s a, Integral a) => M s a
test4'  =   error "urk"

test4   =   wim 4 test4'
--   Integral a0, (Modular s a0 => Modular s1 a1, Integral a1, M s1 a1 ~ M s w0)
--   Under the implication, [D] a1 ~ a0, [W] a1 ~ w0
--   Hence a1 := w0, [D] w0 ~ a0