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