git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Extra instances for Ordering and Unit
70f9360Gary Burgess
prelude/README.md+52−3
@@ -559,7 +559,7 @@ and subtraction operations.
559Instances must satisfy the following law in addition to the `Semiring`
559Instances must satisfy the following law in addition to the `Semiring`
560laws:
560laws:
561
561
562−- Additive inverse: `a + (−a) = (−a) + a = zero`
562+- Additive inverse: `a + (-a) = (-a) + a = zero`
563
563
564#### `ringNumber`
564#### `ringNumber`
565
565
@@ -723,6 +723,13 @@ instance eqArray :: (Eq a) => Eq [a]
723```
723```
724
724
725
725
726+#### `eqOrdering`
727+
728+``` purescript
729+instance eqOrdering :: Eq Ordering
730+```
731+
732+
726#### `Ordering`
733#### `Ordering`
727
734
728``` purescript
735``` purescript
@@ -789,10 +796,10 @@ instance ordArray :: (Ord a) => Ord [a]
789```
796```
790
797
791
798
792−#### `eqOrdering`
799+#### `ordOrdering`
793
800
794``` purescript
801``` purescript
795−instance eqOrdering :: Eq Ordering
802+instance ordOrdering :: Ord Ordering
796```
803```
797
804
798
805
@@ -857,6 +864,13 @@ instance boundedUnit :: Bounded Unit
857```
864```
858
865
859
866
867+#### `boundedOrdering`
868+
869+``` purescript
870+instance boundedOrdering :: Bounded Ordering
871+```
872+
873+
860#### `Lattice`
874#### `Lattice`
861
875
862``` purescript
876``` purescript
@@ -891,6 +905,13 @@ instance latticeBoolean :: Lattice Boolean
891```
905```
892
906
893
907
908+#### `latticeUnit`
909+
910+``` purescript
911+instance latticeUnit :: Lattice Unit
912+```
913+
914+
894#### `(||)`
915#### `(||)`
895
916
896``` purescript
917``` purescript
@@ -933,6 +954,13 @@ instance boundedLatticeBoolean :: BoundedLattice Boolean
933```
954```
934
955
935
956
957+#### `boundedLatticeUnit`
958+
959+``` purescript
960+instance boundedLatticeUnit :: BoundedLattice Unit
961+```
962+
963+
936#### `ComplementedLattice`
964#### `ComplementedLattice`
937
965
938``` purescript
966``` purescript
@@ -959,6 +987,13 @@ instance complementedLatticeBoolean :: ComplementedLattice Boolean
959```
987```
960
988
961
989
990+#### `complementedLatticeUnit`
991+
992+``` purescript
993+instance complementedLatticeUnit :: ComplementedLattice Unit
994+```
995+
996+
962#### `DistributiveLattice`
997#### `DistributiveLattice`
963
998
964``` purescript
999``` purescript
@@ -980,6 +1015,13 @@ instance distributiveLatticeBoolean :: DistributiveLattice Boolean
980```
1015```
981
1016
982
1017
1018+#### `distributiveLatticeUnit`
1019+
1020+``` purescript
1021+instance distributiveLatticeUnit :: DistributiveLattice Unit
1022+```
1023+
1024+
983#### `BooleanAlgebra`
1025#### `BooleanAlgebra`
984
1026
985``` purescript
1027``` purescript
@@ -999,6 +1041,13 @@ instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
999```
1041```
1000
1042
1001
1043
1044+#### `booleanAlgebraUnit`
1045+
1046+``` purescript
1047+instance booleanAlgebraUnit :: BooleanAlgebra Unit
1048+```
1049+
1050+
1002#### `Show`
1051#### `Show`
1003
1052
1004``` purescript
1053``` purescript
prelude/prelude.purs+32−6
@@ -593,6 +593,13 @@ module Prelude
593 (==) = eqArrayImpl (==)
593 (==) = eqArrayImpl (==)
594 (/=) xs ys = not (xs == ys)
594 (/=) xs ys = not (xs == ys)
595
595
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+
596 foreign import refEq
603 foreign import refEq
597 """
604 """
598 function refEq(r1) {
605 function refEq(r1) {
@@ -667,12 +674,14 @@ module Prelude
667 EQ -> compare xs ys
674 EQ -> compare xs ys
668 other -> other
675 other -> other
669
676
670− instance eqOrdering :: Eq Ordering where
677+ instance ordOrdering :: Ord Ordering where
671− (==) LT LT = true
678+ compare LT LT = EQ
672− (==) GT GT = true
679+ compare EQ EQ = EQ
673− (==) EQ EQ = true
680+ compare GT GT = EQ
674− (==) _ _ = false
681+ compare LT _ = LT
675− (/=) x y = not (x == y)
682+ compare EQ LT = GT
683+ compare EQ GT = LT
684+ compare GT _ = GT
676
685
677 infixl 4 <
686 infixl 4 <
678 infixl 4 >
687 infixl 4 >
@@ -739,6 +748,10 @@ module Prelude
739 top = unit
748 top = unit
740 bottom = unit
749 bottom = unit
741
750
751+ instance boundedOrdering :: Bounded Ordering where
752+ top = GT
753+ bottom = LT
754+
742 -- | The `Lattice` type class represents types that are partially ordered
755 -- | The `Lattice` type class represents types that are partially ordered
743 -- | sets with a supremum (`sup` or `||`) and infimum (`inf` or `&&`).
756 -- | sets with a supremum (`sup` or `||`) and infimum (`inf` or `&&`).
744 -- |
757 -- |
@@ -765,6 +778,10 @@ module Prelude
765 sup = boolOr
778 sup = boolOr
766 inf = boolAnd
779 inf = boolAnd
767
780
781+ instance latticeUnit :: Lattice Unit where
782+ sup _ _ = unit
783+ inf _ _ = unit
784+
768 infixr 2 ||
785 infixr 2 ||
769 infixr 3 &&
786 infixr 3 &&
770
787
@@ -792,6 +809,8 @@ module Prelude
792
809
793 instance boundedLatticeBoolean :: BoundedLattice Boolean
810 instance boundedLatticeBoolean :: BoundedLattice Boolean
794
811
812+ instance boundedLatticeUnit :: BoundedLattice Unit
813+
795 -- | The `ComplementedLattice` type class represents types that are lattices
814 -- | The `ComplementedLattice` type class represents types that are lattices
796 -- | where every member is also uniquely complemented.
815 -- | where every member is also uniquely complemented.
797 -- |
816 -- |
@@ -809,6 +828,9 @@ module Prelude
809 instance complementedLatticeBoolean :: ComplementedLattice Boolean where
828 instance complementedLatticeBoolean :: ComplementedLattice Boolean where
810 not = boolNot
829 not = boolNot
811
830
831+ instance complementedLatticeUnit :: ComplementedLattice Unit where
832+ not _ = unit
833+
812 -- | The `DistributiveLattice` type class represents types that are lattices
834 -- | The `DistributiveLattice` type class represents types that are lattices
813 -- | where the `&&` and `||` distribute over each other.
835 -- | where the `&&` and `||` distribute over each other.
814 -- |
836 -- |
@@ -820,6 +842,8 @@ module Prelude
820
842
821 instance distributiveLatticeBoolean :: DistributiveLattice Boolean
843 instance distributiveLatticeBoolean :: DistributiveLattice Boolean
822
844
845+ instance distributiveLatticeUnit :: DistributiveLattice Unit
846+
823 -- | The `BooleanAlgebra` type class represents types that are Boolean
847 -- | The `BooleanAlgebra` type class represents types that are Boolean
824 -- | algebras, also known as Boolean lattices.
848 -- | algebras, also known as Boolean lattices.
825 -- |
849 -- |
@@ -829,6 +853,8 @@ module Prelude
829
853
830 instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
854 instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
831
855
856+ instance booleanAlgebraUnit :: BooleanAlgebra Unit
857+
832 foreign import boolOr
858 foreign import boolOr
833 """
859 """
834 function boolOr(b1) {
860 function boolOr(b1) {