File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 17
17
],
18
18
"dependencies" : {
19
19
"purescript-proxy" : " ^2.0.0" ,
20
- "purescript-symbols" : " ^3.0.0" ,
21
- "purescript-type-equality" : " ^2.0.0"
20
+ "purescript-symbols" : " ^3.0.0"
22
21
}
23
22
}
Original file line number Diff line number Diff line change
1
+ module Type.Equality
2
+ ( class TypeEquals
3
+ , to
4
+ , from
5
+ , class TypeEqualsBool
6
+ ) where
7
+
8
+ import Type.Data.Boolean (kind Boolean , True , False )
9
+
10
+ -- | This type class asserts that types `a` and `b`
11
+ -- | are equal.
12
+ -- |
13
+ -- | The functional dependencies and the single
14
+ -- | instance below will force the two type arguments
15
+ -- | to unify when either one is known.
16
+ -- |
17
+ -- | Note: any instance will necessarily overlap with
18
+ -- | `refl` below, so instances of this class should
19
+ -- | not be defined in libraries.
20
+ class TypeEquals a b | a -> b , b -> a where
21
+ to :: a -> b
22
+ from :: b -> a
23
+
24
+ instance refl :: TypeEquals a a where
25
+ to a = a
26
+ from a = a
27
+
28
+ -- | This type class asserts that types `a` and `b`
29
+ -- | are or are not equal, depending on the type of `o`.
30
+ -- |
31
+ -- | Instances should not be defined in libraries.
32
+ class TypeEqualsBool a b (o :: Boolean ) | a b -> o
33
+
34
+ instance reflTypeEqualsBool :: TypeEqualsBool a a True
35
+ else instance notTypeEqualsBool :: TypeEqualsBool a b False
You can’t perform that action at this time.
0 commit comments