summaryrefslogtreecommitdiff
path: root/testsuite/tests/indexed-types/should_compile/T2238.hs
blob: f2407ac623e97718d462d18348c12bcad817386a (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
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}

-- #2238
-- Notice that class CTF has just one value field, but
-- it also has an equality predicate. 
-- See Note [Class newtypes and equality predicates] in BuildTyCl

module Foo where

data A
data B

-- via functional dependencies

class HowFD a how | a -> how

class HowFD a how => CFD a how where
  cfd :: a -> String
  cfd _ = "cfd"
instance HowFD a how => CFD a how

instance HowFD Bool A

-- via type families

type family HowTF a

class how ~ HowTF a => CTF a how where
  ctf :: a -> String
  ctf _ = "ctf"

instance how ~ HowTF a => CTF a how

type instance HowTF Bool = A