Debian Codegraph @

tests/haskell/Types/TypeFamilies/4/Main.hs

raw symbols SCIP
1 {-# LANGUAGE NoImplicitPrelude #-}
2
3 {- This test creates:
4
5 [W] C a
6 [W] a ~ (Arg a -> Res a)
7
8 Processing the first wanted creates two regular metatypevar's to break the cycle:
9
10 [W] a ~ (cbv1 -> cbv2)
11 [W] C a
12 [W] cbv1 ~ Arg a
13 [W] cbv2 ~ Res a
14
15 We then immediately continue processing [W] a ~ (cbv1 -> cbv2) and substitute for a, yielding:
16
17 [W] C (cbv1 -> cbv2)
18 [W] cbv1 ~ Arg (cbv1 -> cbv2)
19 [W] cbv2 ~ Res (cbv1 -> cbv2)
20
21 The first wanted can then be satisfied via the class instance for C.
22 The remaining wanteds are reduced to reflexivites via the type instances for Arg and Res.
23
24 -}
25
26 type family Arg a
27 type family Res a
28
29 type instance Arg (c -> d) = c
30 type instance Res (c -> d) = d
31
32 class C a where
33 method :: a -> a
34
35 instance C (a -> b) where
36 method x = x
37
38 foo :: (a ~ (Arg a -> Res a)) => a -> a
39 foo x = x
40
41 func x = method (foo x)