705db9eb2865a5a921549f50e28550808737c6af
[ghc.git] / libraries / base / Data / Type / Bool.hs
1 {-# LANGUAGE TypeFamilies, TypeOperators, DataKinds, NoImplicitPrelude,
2 PolyKinds #-}
3
4 -----------------------------------------------------------------------------
5 -- |
6 -- Module : Data.Type.Bool
7 -- License : BSD-style (see the LICENSE file in the distribution)
8 --
9 -- Maintainer : libraries@haskell.org
10 -- Stability : experimental
11 -- Portability : not portable
12 --
13 -- Basic operations on type-level Booleans.
14 --
15 -- /Since: 4.7.0.0/
16 -----------------------------------------------------------------------------
17
18 module Data.Type.Bool (
19 If, type (&&), type (||), Not
20 ) where
21
22 import Data.Bool
23
24 -- This needs to be in base because (&&) is used in Data.Type.Equality.
25 -- The other functions do not need to be in base, but seemed to be appropriate
26 -- here.
27
28 -- | Type-level "If". @If True a b@ ==> @a@; @If False a b@ ==> @b@
29 type family If cond tru fls where
30 If True tru fls = tru
31 If False tru fls = fls
32
33 -- | Type-level "and"
34 type family a && b where
35 False && a = False
36 True && a = a
37 a && False = False
38 a && True = a
39 a && a = a
40 infixr 3 &&
41
42 -- | Type-level "or"
43 type family a || b where
44 False || a = a
45 True || a = True
46 a || False = a
47 a || True = True
48 a || a = a
49 infixr 2 ||
50
51 -- | Type-level "not"
52 type family Not a where
53 Not False = True
54 Not True = False
55
56