Update Trac ticket URLs to point to GitLab
[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 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 -- Oct 14: actually this example is _really_ strange, and doesn't illustrate
24 -- the real issue in #4935, for which there is a separate test
25 --
26 -- The example here requires us to infer a type
27 -- bar :: F Int ~ [a] => ...
28 -- which is a strange type to quantify over; better to complain about
29 -- having no instance for F Int.
30
31