git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Extra instances for Ordering and Unit
commit70f9360956a5fa61149fbc7638cad9b0c2f4bccc authorGary Burgess <gary.burgess@gmail.com> dateSun 5 Apr 2015, 14:59 (12 years ago) parent240d1e8
2 files changed+84−9
prelude/README.md+52−3 prelude/prelude.purs+32−6
prelude/README.md+52−3
@@ -559,7 +559,7 @@ and subtraction operations.
559559Instances must satisfy the following law in addition to the `Semiring`
560560laws:
561561
562−- Additive inverse: `a + (−a) = (−a) + a = zero`
562+- Additive inverse: `a + (-a) = (-a) + a = zero`
563563
564564#### `ringNumber`
565565
@@ -723,6 +723,13 @@ instance eqArray :: (Eq a) => Eq [a]
723723```
724724
725725
726+#### `eqOrdering`
727+
728+``` purescript
729+instance eqOrdering :: Eq Ordering
730+```
731+
732+
726733#### `Ordering`
727734
728735``` purescript
@@ -789,10 +796,10 @@ instance ordArray :: (Ord a) => Ord [a]
789796```
790797
791798
792−#### `eqOrdering`
799+#### `ordOrdering`
793800
794801``` purescript
795−instance eqOrdering :: Eq Ordering
802+instance ordOrdering :: Ord Ordering
796803```
797804
798805
@@ -857,6 +864,13 @@ instance boundedUnit :: Bounded Unit
857864```
858865
859866
867+#### `boundedOrdering`
868+
869+``` purescript
870+instance boundedOrdering :: Bounded Ordering
871+```
872+
873+
860874#### `Lattice`
861875
862876``` purescript
@@ -891,6 +905,13 @@ instance latticeBoolean :: Lattice Boolean
891905```
892906
893907
908+#### `latticeUnit`
909+
910+``` purescript
911+instance latticeUnit :: Lattice Unit
912+```
913+
914+
894915#### `(||)`
895916
896917``` purescript
@@ -933,6 +954,13 @@ instance boundedLatticeBoolean :: BoundedLattice Boolean
933954```
934955
935956
957+#### `boundedLatticeUnit`
958+
959+``` purescript
960+instance boundedLatticeUnit :: BoundedLattice Unit
961+```
962+
963+
936964#### `ComplementedLattice`
937965
938966``` purescript
@@ -959,6 +987,13 @@ instance complementedLatticeBoolean :: ComplementedLattice Boolean
959987```
960988
961989
990+#### `complementedLatticeUnit`
991+
992+``` purescript
993+instance complementedLatticeUnit :: ComplementedLattice Unit
994+```
995+
996+
962997#### `DistributiveLattice`
963998
964999``` purescript
@@ -980,6 +1015,13 @@ instance distributiveLatticeBoolean :: DistributiveLattice Boolean
9801015```
9811016
9821017
1018+#### `distributiveLatticeUnit`
1019+
1020+``` purescript
1021+instance distributiveLatticeUnit :: DistributiveLattice Unit
1022+```
1023+
1024+
9831025#### `BooleanAlgebra`
9841026
9851027``` purescript
@@ -999,6 +1041,13 @@ instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
9991041```
10001042
10011043
1044+#### `booleanAlgebraUnit`
1045+
1046+``` purescript
1047+instance booleanAlgebraUnit :: BooleanAlgebra Unit
1048+```
1049+
1050+
10021051#### `Show`
10031052
10041053``` purescript
prelude/prelude.purs+32−6
@@ -593,6 +593,13 @@ module Prelude
593593 (==) = eqArrayImpl (==)
594594 (/=) xs ys = not (xs == ys)
595595
596+ instance eqOrdering :: Eq Ordering where
597+ (==) LT LT = true
598+ (==) GT GT = true
599+ (==) EQ EQ = true
600+ (==) _ _ = false
601+ (/=) x y = not (x == y)
602+
596603 foreign import refEq
597604 """
598605 function refEq(r1) {
@@ -667,12 +674,14 @@ module Prelude
667674 EQ -> compare xs ys
668675 other -> other
669676
670− instance eqOrdering :: Eq Ordering where
671− (==) LT LT = true
672− (==) GT GT = true
673− (==) EQ EQ = true
674− (==) _ _ = false
675− (/=) x y = not (x == y)
677+ instance ordOrdering :: Ord Ordering where
678+ compare LT LT = EQ
679+ compare EQ EQ = EQ
680+ compare GT GT = EQ
681+ compare LT _ = LT
682+ compare EQ LT = GT
683+ compare EQ GT = LT
684+ compare GT _ = GT
676685
677686 infixl 4 <
678687 infixl 4 >
@@ -739,6 +748,10 @@ module Prelude
739748 top = unit
740749 bottom = unit
741750
751+ instance boundedOrdering :: Bounded Ordering where
752+ top = GT
753+ bottom = LT
754+
742755 -- | The `Lattice` type class represents types that are partially ordered
743756 -- | sets with a supremum (`sup` or `||`) and infimum (`inf` or `&&`).
744757 -- |
@@ -765,6 +778,10 @@ module Prelude
765778 sup = boolOr
766779 inf = boolAnd
767780
781+ instance latticeUnit :: Lattice Unit where
782+ sup _ _ = unit
783+ inf _ _ = unit
784+
768785 infixr 2 ||
769786 infixr 3 &&
770787
@@ -792,6 +809,8 @@ module Prelude
792809
793810 instance boundedLatticeBoolean :: BoundedLattice Boolean
794811
812+ instance boundedLatticeUnit :: BoundedLattice Unit
813+
795814 -- | The `ComplementedLattice` type class represents types that are lattices
796815 -- | where every member is also uniquely complemented.
797816 -- |
@@ -809,6 +828,9 @@ module Prelude
809828 instance complementedLatticeBoolean :: ComplementedLattice Boolean where
810829 not = boolNot
811830
831+ instance complementedLatticeUnit :: ComplementedLattice Unit where
832+ not _ = unit
833+
812834 -- | The `DistributiveLattice` type class represents types that are lattices
813835 -- | where the `&&` and `||` distribute over each other.
814836 -- |
@@ -820,6 +842,8 @@ module Prelude
820842
821843 instance distributiveLatticeBoolean :: DistributiveLattice Boolean
822844
845+ instance distributiveLatticeUnit :: DistributiveLattice Unit
846+
823847 -- | The `BooleanAlgebra` type class represents types that are Boolean
824848 -- | algebras, also known as Boolean lattices.
825849 -- |
@@ -829,6 +853,8 @@ module Prelude
829853
830854 instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
831855
856+ instance booleanAlgebraUnit :: BooleanAlgebra Unit
857+
832858 foreign import boolOr
833859 """
834860 function boolOr(b1) {