0117b81d473827882bb3173645d64438167fd386
[ghc.git] / testsuite / tests / indexed-types / should_compile / PushedInAsGivens.hs
1 {-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, FlexibleContexts, TypeFamilies #-}
2 module PushedInAsGivens where
3
4
5 type family F a
6
7
8
9 bar y = let foo :: (F Int ~ [a]) => a -> Int
10 foo x = length [x,y]
11 in (y,foo y)
12
13
14 -- This example demonstrates why we need to push in
15 -- an unsolved wanted as a given and not a given/solved.
16 -- [Wanted] F Int ~ [beta]
17 --- forall a. F Int ~ [a] => a ~ beta
18 -- We we push in the [Wanted] as given, it will interact and solve the implication
19 -- constraint, and finally we quantify over F Int ~ [beta]. If we push it in as
20 -- Given/Solved, it will be discarded when we meet the given (F Int ~ [a]) and
21 -- we will not be able to solve the implication constraint.
22
23
24