summaryrefslogtreecommitdiff
path: root/testsuite/tests/ghc-regress/typecheck/testeq1/FakePrelude.hs
blob: 80161655d036d16378a5f55ecf1fb158716565f2 (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
40
41
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies,
             OverlappingInstances, UndecidableInstances #-}

--
-- Test case adopted from the HList library
-- http://www.cwi.nl/~ralf/HList/
--

module FakePrelude where


--
-- Type-level Booleans; nothing weird
--
data HTrue; hTrue :: HTrue; hTrue = undefined
data HFalse; hFalse :: HFalse; hFalse = undefined
class HBool x; instance HBool HTrue; instance HBool HFalse
instance Show HTrue where show _ = "HTrue"
instance Show HFalse where show _ = "HFalse"


--
-- Type-level type equality
--
class HBool b => TypeEq x y b | x y -> b


--
-- Value-level incarnation; nothing too weird.
-- Rely on lazy show for type-level Booleans
--
typeEq :: TypeEq t t' b => t -> t' -> b
typeEq = undefined


--
-- Type-level cast
--
class TypeCast x y | x -> y, y -> x
 where
  typeCast :: x -> y