@@ -1,5 +1,6 @@
1module Prelude
1module Prelude
2− ( otherwise
3+ , otherwise
@@ -13,15 +14,15 @@ module Prelude
13 , Applicative, pure, liftA1
14 , Applicative, pure, liftA1
14 , Bind, (>>=)
15 , Bind, (>>=)
15 , Monad, return, liftM1, ap
16 , Monad, return, liftM1, ap
17+ , Semigroup, (<>), (++)
16 , Semiring, (+), zero, (*), one
18 , Semiring, (+), zero, (*), one
17 , ModuloSemiring, (/), mod
19 , ModuloSemiring, (/), mod
18− , Ring, (-)
20+ , Ring, (-), negate
23 , Eq, (==), (/=)
24 , Eq, (==), (/=)
24− , Ord, Ordering(..), compare, (<), (>), (<=), (>=)
25+ , Ordering(..), Ord, compare, (<), (>), (<=), (>=)
25 , Bounded, top, bottom
26 , Bounded, top, bottom
26 , Lattice, sup, inf, (||), (&&)
27 , Lattice, sup, inf, (||), (&&)
27 , BoundedLattice
28 , BoundedLattice
@@ -29,17 +30,24 @@ module Prelude
29 , DistributiveLattice
30 , DistributiveLattice
30 , BooleanAlgebra
31 , BooleanAlgebra
31 , Bits, (.&.), (.|.), (.^.), shl, shr, zshr, complement
32 , Bits, (.&.), (.|.), (.^.), shl, shr, zshr, complement
32− , Semigroup, (<>), (++)
35+ -- | The `Unit` type has a single inhabitant, called `unit`. It represents values with no computational content.
37+ -- | `Unit` is often used, wrapped in a monadic type constructor, as the return type of a computation where only
38+ -- | the _effects_ are important.
39+ newtype Unit = Unit {}
41+ -- | `unit` is the sole inhabitant of the `Unit` type.
36 -- | An alias for `true`, which can be useful in guard clauses:
45 -- | An alias for `true`, which can be useful in guard clauses:
38 -- | ```purescript
47 -- | ```purescript
39 -- | max x y | x >= y = x
48 -- | max x y | x >= y = x
40 -- | | otherwise = y
49 -- | | otherwise = y
43 otherwise :: Boolean
51 otherwise :: Boolean
44 otherwise = true
52 otherwise = true
@@ -48,7 +56,6 @@ module Prelude
48 -- | ```purescript
56 -- | ```purescript
49 -- | flip const 1 2 = const 2 1 = 2
57 -- | flip const 1 2 = const 2 1 = 2
52 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
59 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
53 flip f b a = f a b
60 flip f b a = f a b
@@ -57,7 +64,6 @@ module Prelude
57 -- | ```purescript
64 -- | ```purescript
58 -- | const 1 "hello" = 1
65 -- | const 1 "hello" = 1
61 const :: forall a b. a -> b -> a
67 const :: forall a b. a -> b -> a
62 const a _ = a
68 const a _ = a
@@ -102,7 +108,6 @@ module Prelude
103 -- | - Left Identity: `id <<< p = p`
109 -- | - Left Identity: `id <<< p = p`
104 -- | - Right Identity: `p <<< id = p`
110 -- | - Right Identity: `p <<< id = p`
106 class (Semigroupoid a) <= Category a where
111 class (Semigroupoid a) <= Category a where
107 id :: forall t. a t t
112 id :: forall t. a t t
@@ -126,7 +131,6 @@ module Prelude
127 -- | `($)` is different from [`(#)`](#-2) because it is right-infix instead of left, so
132 -- | `($)` is different from [`(#)`](#-2) because it is right-infix instead of left, so
128 -- | `a $ b $ c $ d x` = `a $ (b $ (c $ (d $ x)))` = `a (b (c (d x)))`
133 -- | `a $ b $ c $ d x` = `a $ (b $ (c $ (d $ x)))` = `a (b (c (d x)))`
130 ($) :: forall a b. (a -> b) -> a -> b
134 ($) :: forall a b. (a -> b) -> a -> b
131 ($) f x = f x
135 ($) f x = f x
@@ -144,7 +148,6 @@ module Prelude
145 -- | `(#)` is different from [`($)`](#-1) because it is left-infix instead of right, so
149 -- | `(#)` is different from [`($)`](#-1) because it is left-infix instead of right, so
146 -- | `x # a # b # c # d` = `(((x # a) # b) # c) # d` = `d (c (b (a x)))`
150 -- | `x # a # b # c # d` = `(((x # a) # b) # c) # d` = `d (c (b (a x)))`
148 (#) :: forall a b. a -> (a -> b) -> b
151 (#) :: forall a b. a -> (a -> b) -> b
149 (#) x f = f x
152 (#) x f = f x
@@ -179,22 +182,26 @@ module Prelude
179 class Show a where
182 class Show a where
180 show :: a -> String
183 show :: a -> String
182− foreign import showStringImpl
185+ instance showBoolean :: Show Boolean where
183− """
186+ show true = "true"
184− function showStringImpl(s) {
187+ show false = "false"
185− return JSON.stringify(s);
187− """ :: String -> String
189− instance showUnit :: Show Unit where
189+ instance showNumber :: Show Number where
190− show (Unit {}) = "Unit {}"
190+ show = showNumberImpl
192 instance showString :: Show String where
192 instance showString :: Show String where
193 show = showStringImpl
193 show = showStringImpl
195− instance showBoolean :: Show Boolean where
195+ instance showUnit :: Show Unit where
196− show true = "true"
196+ show _ = "unit"
197− show false = "false"
197+
198+ instance showArray :: (Show a) => Show [a] where
199+ show = showArrayImpl show
201+ instance showOrdering :: Show Ordering where
199 foreign import showNumberImpl
206 foreign import showNumberImpl
@@ -203,8 +210,12 @@ module Prelude
204 """ :: Number -> String
211 """ :: Number -> String
206− instance showNumber :: Show Number where
213+ foreign import showStringImpl
207− show = showNumberImpl
214+ """
215+ function showStringImpl(s) {
216+ return JSON.stringify(s);
218+ """ :: String -> String
209 foreign import showArrayImpl
220 foreign import showArrayImpl
@@ -219,9 +230,6 @@ module Prelude
220 """ :: forall a. (a -> String) -> [a] -> String
231 """ :: forall a. (a -> String) -> [a] -> String
222− instance showArray :: (Show a) => Show [a] where
223− show = showArrayImpl show
225 infixl 4 <$>
233 infixl 4 <$>
226 infixl 1 <#>
234 infixl 1 <#>
@@ -234,10 +242,12 @@ module Prelude
235 -- | - Identity: `(<$>) id = id`
243 -- | - Identity: `(<$>) id = id`
236 -- | - Composition: `(<$>) (f <<< g) = (f <$>) <<< (g <$>)`
244 -- | - Composition: `(<$>) (f <<< g) = (f <$>) <<< (g <$>)`
238 class Functor f where
245 class Functor f where
239 (<$>) :: forall a b. (a -> b) -> f a -> f b
246 (<$>) :: forall a b. (a -> b) -> f a -> f b
248+ instance functorArr :: Functor ((->) r) where
241 -- | `(<#>)` is `(<$>)` with its arguments reversed. For example:
251 -- | `(<#>)` is `(<$>)` with its arguments reversed. For example:
243 -- | ```purescript
253 -- | ```purescript
@@ -282,6 +292,9 @@ module Prelude
282 class (Functor f) <= Apply f where
292 class (Functor f) <= Apply f where
283 (<*>) :: forall a b. f (a -> b) -> f a -> f b
293 (<*>) :: forall a b. f (a -> b) -> f a -> f b
295+ instance applyArr :: Apply ((->) r) where
296+ (<*>) f g x = f x (g x)
285 -- | The `Applicative` type class extends the [`Apply`](#apply) type class with a `pure` function, which can be used to
298 -- | The `Applicative` type class extends the [`Apply`](#apply) type class with a `pure` function, which can be used to
286 -- | create values of type `f a` from values of type `a`.
299 -- | create values of type `f a` from values of type `a`.
@@ -295,10 +308,16 @@ module Prelude
295 -- | - Composition: `(pure <<<) <*> f <*> g <*> h = f <*> (g <*> h)`
308 -- | - Composition: `(pure <<<) <*> f <*> g <*> h = f <*> (g <*> h)`
296 -- | - Homomorphism: `(pure f) <*> (pure x) = pure (f x)`
309 -- | - Homomorphism: `(pure f) <*> (pure x) = pure (f x)`
297 -- | - Interchange: `u <*> (pure y) = (pure ($ y)) <*> u`
310 -- | - Interchange: `u <*> (pure y) = (pure ($ y)) <*> u`
299 class (Apply f) <= Applicative f where
311 class (Apply f) <= Applicative f where
300 pure :: forall a. a -> f a
312 pure :: forall a. a -> f a
314+ instance applicativeArr :: Applicative ((->) r) where
317+ -- | `return` is an alias for `pure`.
318+ return :: forall m a. (Applicative m) => a -> m a
302 -- | `liftA1` provides a default implementation of `(<$>)` for any [`Applicative`](#applicative) functor,
321 -- | `liftA1` provides a default implementation of `(<$>)` for any [`Applicative`](#applicative) functor,
303 -- | without using `(<$>)` as provided by the [`Functor`](#functor)-[`Applicative`](#applicative) superclass relationship.
322 -- | without using `(<$>)` as provided by the [`Functor`](#functor)-[`Applicative`](#applicative) superclass relationship.
@@ -343,6 +362,9 @@ module Prelude
343 class (Apply m) <= Bind m where
362 class (Apply m) <= Bind m where
344 (>>=) :: forall a b. m a -> (a -> m b) -> m b
363 (>>=) :: forall a b. m a -> (a -> m b) -> m b
365+ instance bindArr :: Bind ((->) r) where
366+ (>>=) m f x = f (m x) x
346 -- | The `Monad` type class combines the operations of the `Bind` and `Applicative` type classes. Therefore, `Monad` instances
368 -- | The `Monad` type class combines the operations of the `Bind` and `Applicative` type classes. Therefore, `Monad` instances
347 -- | represent type constructors which support sequential composition, and also lifting of functions of arbitrary arity.
369 -- | represent type constructors which support sequential composition, and also lifting of functions of arbitrary arity.
@@ -355,12 +377,9 @@ module Prelude
356 -- | - Left Identity: `do { y <- pure x ; f y } = f x`
378 -- | - Left Identity: `do { y <- pure x ; f y } = f x`
357 -- | - Right Identity: `do { y <- x ; pure y } = x`
379 -- | - Right Identity: `do { y <- x ; pure y } = x`
359 class (Applicative m, Bind m) <= Monad m
380 class (Applicative m, Bind m) <= Monad m
361− -- | `return` is an alias for `pure`.
382+ instance monadArr :: Monad ((->) r)
362− return :: forall m a. (Monad m) => a -> m a
365 -- | `liftM1` provides a default implementation of `(<$>)` for any [`Monad`](#monad),
384 -- | `liftM1` provides a default implementation of `(<$>)` for any [`Monad`](#monad),
366 -- | without using `(<$>)` as provided by the [`Functor`](#functor)-[`Monad`](#monad) superclass relationship.
385 -- | without using `(<$>)` as provided by the [`Functor`](#functor)-[`Monad`](#monad) superclass relationship.
@@ -391,26 +410,48 @@ module Prelude
392 return (f' a')
411 return (f' a')
394− instance functorArr :: Functor ((->) r) where
413+ infixr 5 <>
395− (<$>) = (<<<)
414+ infixr 5 ++
397− instance applyArr :: Apply ((->) r) where
416+ -- | The `Semigroup` type class identifies an associative operation on a type.
398− (<*>) f g x = f x (g x)
417+ -- |
418+ -- | `Semigroup` instances are required to satisfy the following law:
420+ -- | - Associativity: `(x <> y) <> z = x <> (y <> z)`
422+ -- | For example, the `String` type is an instance of `Semigroup`, where `(<>)` is defined to be string concatenation.
423+ class Semigroup a where
400− instance applicativeArr :: Applicative ((->) r) where
426+ -- | `(++)` is an alias for `(<>)`.
401− pure = const
427+ (++) :: forall s. (Semigroup s) => s -> s -> s
403− instance bindArr :: Bind ((->) r) where
430+ instance semigroupString :: Semigroup String where
404− (>>=) m f x = f (m x) x
431+ (<>) = concatString
406− instance monadArr :: Monad ((->) r)
433+ instance semigroupUnit :: Semigroup Unit where
408− infixl 7 *
436+ instance semigroupArr :: (Semigroup s') => Semigroup (s -> s') where
409− infixl 7 /
437+ (<>) f g = \x -> f x <> g x
439+ instance semigroupOrdering :: Semigroup Ordering where
444+ foreign import concatString
446+ function concatString(s1) {
447+ return function(s2) {
451+ """ :: String -> String -> String
413 infixl 6 +
453 infixl 6 +
415 -- | Addition and multiplication, satisfying the following laws:
456 -- | Addition and multiplication, satisfying the following laws:
@@ -418,42 +459,79 @@ module Prelude
418 -- | - `a` is a monoid under multiplication
459 -- | - `a` is a monoid under multiplication
419 -- | - multiplication distributes over addition
460 -- | - multiplication distributes over addition
420 -- | - multiplication by `zero` annihilates `a`
461 -- | - multiplication by `zero` annihilates `a`
422 class Semiring a where
462 class Semiring a where
423 (+) :: a -> a -> a
463 (+) :: a -> a -> a
424 zero :: a
464 zero :: a
425 (*) :: a -> a -> a
465 (*) :: a -> a -> a
468+ instance semiringNumber :: Semiring Number where
474+ instance semiringUnit :: Semiring Unit where
428 -- | Addition, multiplication, modulo operation and division, satisfying:
482 -- | Addition, multiplication, modulo operation and division, satisfying:
430 -- | - ```a / b * b + (a `mod` b) = a```
484 -- | - ```a / b * b + (a `mod` b) = a```
432 class (Semiring a) <= ModuloSemiring a where
485 class (Semiring a) <= ModuloSemiring a where
433 (/) :: a -> a -> a
486 (/) :: a -> a -> a
434 mod :: a -> a -> a
487 mod :: a -> a -> a
489+ instance moduloSemiringNumber :: ModuloSemiring Number where
493+ instance moduloSemiringUnit :: ModuloSemiring Unit where
436 -- | Addition, multiplication, and subtraction.
499 -- | Addition, multiplication, and subtraction.
438 -- | Has the same laws as `Semiring` but additionally satisfying:
501 -- | Has the same laws as `Semiring` but additionally satisfying:
440 -- | - `a` is an abelian group under addition
503 -- | - `a` is an abelian group under addition
442 class (Semiring a) <= Ring a where
504 class (Semiring a) <= Ring a where
443 (-) :: a -> a -> a
505 (-) :: a -> a -> a
507+ instance ringNumber :: Ring Number where
510+ instance ringUnit :: Ring Unit where
445 negate :: forall a. (Ring a) => a -> a
513 negate :: forall a. (Ring a) => a -> a
446 negate a = zero - a
514 negate a = zero - a
448 -- | Ring where every nonzero element has a multiplicative inverse so that:
516 -- | Ring where every nonzero element has a multiplicative inverse so that:
450 -- | - ```a `mod` b = zero```
518 -- | - ```a `mod` b = zero```
452 class (Ring a, ModuloSemiring a) <= DivisionRing a
519 class (Ring a, ModuloSemiring a) <= DivisionRing a
521+ instance divisionRingNumber :: DivisionRing Number
523+ instance divisionRingUnit :: DivisionRing Unit
454 -- | A commutative field
525 -- | A commutative field
455 class (DivisionRing a) <= Num a
526 class (DivisionRing a) <= Num a
528+ instance numNumber :: Num Number
530+ instance numUnit :: Num Unit
457 foreign import numAdd
535 foreign import numAdd
459 function numAdd(n1) {
537 function numAdd(n1) {
@@ -463,15 +541,6 @@ module Prelude
464 """ :: Number -> Number -> Number
542 """ :: Number -> Number -> Number
466− foreign import numSub
468− function numSub(n1) {
469− return function(n2) {
473− """ :: Number -> Number -> Number
475 foreign import numMul
544 foreign import numMul
477 function numMul(n1) {
546 function numMul(n1) {
@@ -490,6 +559,15 @@ module Prelude
491 """ :: Number -> Number -> Number
560 """ :: Number -> Number -> Number
562+ foreign import numSub
564+ function numSub(n1) {
565+ return function(n2) {
569+ """ :: Number -> Number -> Number
493 foreign import numMod
571 foreign import numMod
495 function numMod(n1) {
573 function numMod(n1) {
@@ -499,35 +577,6 @@ module Prelude
500 """ :: Number -> Number -> Number
578 """ :: Number -> Number -> Number
504− instance semiringNumber :: Semiring Number where
510− instance ringNumber :: Ring Number where
513− instance moduloSemiringNumber :: ModuloSemiring Number where
517− instance divisionRingNumber :: DivisionRing Number
519− instance numNumber :: Num Number
521− -- | The `Unit` type has a single inhabitant, called `unit`. It represents values with no computational content.
523− -- | `Unit` is often used, wrapped in a monadic type constructor, as the return type of a computation where only
524− -- | the _effects_ are important.
525− newtype Unit = Unit {}
527− -- | `unit` is the sole inhabitant of the `Unit` type.
531 infix 4 ==
580 infix 4 ==
532 infix 4 /=
581 infix 4 /=
@@ -545,6 +594,26 @@ module Prelude
545 (==) :: a -> a -> Boolean
594 (==) :: a -> a -> Boolean
546 (/=) :: a -> a -> Boolean
595 (/=) :: a -> a -> Boolean
597+ instance eqBoolean :: Eq Boolean where
601+ instance eqNumber :: Eq Number where
605+ instance eqString :: Eq String where
609+ instance eqUnit :: Eq Unit where
613+ instance eqArray :: (Eq a) => Eq [a] where
614+ (==) = eqArrayImpl (==)
615+ (/=) xs ys = not (xs == ys)
548 foreign import refEq
617 foreign import refEq
550 function refEq(r1) {
619 function refEq(r1) {
@@ -563,22 +632,6 @@ module Prelude
564 """ :: forall a. a -> a -> Boolean
633 """ :: forall a. a -> a -> Boolean
566− instance eqUnit :: Eq Unit where
567− (==) (Unit {}) (Unit {}) = true
568− (/=) (Unit {}) (Unit {}) = false
570− instance eqString :: Eq String where
574− instance eqNumber :: Eq Number where
578− instance eqBoolean :: Eq Boolean where
582 foreign import eqArrayImpl
635 foreign import eqArrayImpl
584 function eqArrayImpl(f) {
637 function eqArrayImpl(f) {
@@ -594,10 +647,6 @@ module Prelude
595 """ :: forall a. (a -> a -> Boolean) -> [a] -> [a] -> Boolean
648 """ :: forall a. (a -> a -> Boolean) -> [a] -> [a] -> Boolean
597− instance eqArray :: (Eq a) => Eq [a] where
598− (==) xs ys = eqArrayImpl (==) xs ys
599− (/=) xs ys = not (xs == ys)
601 -- | The `Ordering` data type represents the three possible outcomes of comparing two values:
650 -- | The `Ordering` data type represents the three possible outcomes of comparing two values:
603 -- | `LT` - The first value is _less than_ the second.
652 -- | `LT` - The first value is _less than_ the second.
@@ -605,23 +654,6 @@ module Prelude
605 -- | `EQ` - The first value is _equal to_ or _incomparable to_ the second.
654 -- | `EQ` - The first value is _equal to_ or _incomparable to_ the second.
606 data Ordering = LT | GT | EQ
655 data Ordering = LT | GT | EQ
608− instance eqOrdering :: Eq Ordering where
613− (/=) x y = not (x == y)
615− instance showOrdering :: Show Ordering where
620− instance semigroupOrdering :: Semigroup Ordering where
625 -- | The `Ord` type class represents types which support comparisons.
657 -- | The `Ord` type class represents types which support comparisons.
627 -- | `Ord` instances should satisfy the laws of _partially orderings_:
659 -- | `Ord` instances should satisfy the laws of _partially orderings_:
@@ -629,11 +661,43 @@ module Prelude
629 -- | - Reflexivity: `a <= a`
661 -- | - Reflexivity: `a <= a`
630 -- | - Antisymmetry: if `a <= b` and `b <= a` then `a = b`
662 -- | - Antisymmetry: if `a <= b` and `b <= a` then `a = b`
631 -- | - Transitivity: if `a <= b` and `b <= c` then `a <= c`
663 -- | - Transitivity: if `a <= b` and `b <= c` then `a <= c`
633 class (Eq a) <= Ord a where
664 class (Eq a) <= Ord a where
634 compare :: a -> a -> Ordering
665 compare :: a -> a -> Ordering
667+ instance ordBoolean :: Ord Boolean where
668+ compare false false = EQ
669+ compare false true = LT
670+ compare true true = EQ
671+ compare true false = GT
673+ instance ordNumber :: Ord Number where
674+ compare = unsafeCompare
676+ instance ordString :: Ord String where
677+ compare = unsafeCompare
679+ instance ordUnit :: Ord Unit where
682+ instance ordArray :: (Ord a) => Ord [a] where
686+ compare (x:xs) (y:ys) = case compare x y of
690+ instance eqOrdering :: Eq Ordering where
695+ (/=) x y = not (x == y)
636 infixl 4 <
697 infixl 4 <
638 -- | Test whether one value is _strictly less than_ another.
702 -- | Test whether one value is _strictly less than_ another.
639 (<) :: forall a. (Ord a) => a -> a -> Boolean
703 (<) :: forall a. (Ord a) => a -> a -> Boolean
@@ -641,30 +705,27 @@ module Prelude
641 LT -> true
705 LT -> true
642 _ -> false
706 _ -> false
646 -- | Test whether one value is _strictly greater than_ another.
708 -- | Test whether one value is _strictly greater than_ another.
647 (>) :: forall a. (Ord a) => a -> a -> Boolean
709 (>) :: forall a. (Ord a) => a -> a -> Boolean
648 (>) a1 a2 = case a1 `compare` a2 of
710 (>) a1 a2 = case a1 `compare` a2 of
649 GT -> true
711 GT -> true
650 _ -> false
712 _ -> false
654 -- | Test whether one value is _non-strictly less than_ another.
714 -- | Test whether one value is _non-strictly less than_ another.
655 (<=) :: forall a. (Ord a) => a -> a -> Boolean
715 (<=) :: forall a. (Ord a) => a -> a -> Boolean
656 (<=) a1 a2 = case a1 `compare` a2 of
716 (<=) a1 a2 = case a1 `compare` a2 of
657 GT -> false
717 GT -> false
658 _ -> true
718 _ -> true
662 -- | Test whether one value is _non-strictly greater than_ another.
720 -- | Test whether one value is _non-strictly greater than_ another.
663 (>=) :: forall a. (Ord a) => a -> a -> Boolean
721 (>=) :: forall a. (Ord a) => a -> a -> Boolean
664 (>=) a1 a2 = case a1 `compare` a2 of
722 (>=) a1 a2 = case a1 `compare` a2 of
665 LT -> false
723 LT -> false
666 _ -> true
724 _ -> true
726+ unsafeCompare :: forall a. a -> a -> Ordering
727+ unsafeCompare = unsafeCompareImpl LT EQ GT
668 foreign import unsafeCompareImpl
729 foreign import unsafeCompareImpl
670 function unsafeCompareImpl(lt) {
731 function unsafeCompareImpl(lt) {
@@ -680,32 +741,6 @@ module Prelude
681 """ :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
742 """ :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
683− unsafeCompare :: forall a. a -> a -> Ordering
684− unsafeCompare = unsafeCompareImpl LT EQ GT
686− instance ordUnit :: Ord Unit where
687− compare (Unit {}) (Unit {}) = EQ
689− instance ordBoolean :: Ord Boolean where
690− compare false false = EQ
691− compare false true = LT
692− compare true true = EQ
693− compare true false = GT
695− instance ordNumber :: Ord Number where
696− compare = unsafeCompare
698− instance ordString :: Ord String where
699− compare = unsafeCompare
701− instance ordArray :: (Ord a) => Ord [a] where
705− compare (x:xs) (y:ys) = case compare x y of
709 -- | The `Bounded` type class represents types that are finite partially
744 -- | The `Bounded` type class represents types that are finite partially
710 -- | ordered sets.
745 -- | ordered sets.
@@ -720,6 +755,10 @@ module Prelude
720 top = true
755 top = true
721 bottom = false
756 bottom = false
758+ instance boundedUnit :: Bounded Unit where
723 -- | The `Lattice` type class represents types that are partially ordered
762 -- | The `Lattice` type class represents types that are partially ordered
724 -- | sets with a supremum (`sup` or `||`) and infimum (`inf` or `&&`).
763 -- | sets with a supremum (`sup` or `||`) and infimum (`inf` or `&&`).
@@ -746,6 +785,17 @@ module Prelude
746 sup = boolOr
785 sup = boolOr
747 inf = boolAnd
786 inf = boolAnd
791+ -- | The `sup` operator.
792+ (||) :: forall a. (Lattice a) => a -> a -> a
795+ -- | The `inf` operator.
796+ (&&) :: forall a. (Lattice a) => a -> a -> a
749 -- | The `BoundedLattice` type class represents types that are finite
799 -- | The `BoundedLattice` type class represents types that are finite
750 -- | lattices.
800 -- | lattices.
@@ -799,35 +849,23 @@ module Prelude
800 instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
850 instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
804− -- | The `sup` operator.
805− (||) :: forall a. (Lattice a) => a -> a -> a
810− -- | The `inf` operator.
811− (&&) :: forall a. (Lattice a) => a -> a -> a
814− foreign import boolAnd
852+ foreign import boolOr
816− function boolAnd(b1) {
854+ function boolOr(b1) {
817 return function(b2) {
855 return function(b2) {
818− return b1 && b2;
856+ return b1 || b2;
821− """ :: Boolean -> Boolean -> Boolean
859+ """ :: Boolean -> Boolean -> Boolean
823− foreign import boolOr
861+ foreign import boolAnd
825− function boolOr(b1) {
863+ function boolAnd(b1) {
826 return function(b2) {
864 return function(b2) {
827− return b1 || b2;
865+ return b1 && b2;
830− """ :: Boolean -> Boolean -> Boolean
868+ """ :: Boolean -> Boolean -> Boolean
832 foreign import boolNot
870 foreign import boolNot
@@ -836,42 +874,6 @@ module Prelude
837 """ :: Boolean -> Boolean
875 """ :: Boolean -> Boolean
841− -- | The `Semigroup` type class identifies an associative operation on a type.
843− -- | `Semigroup` instances are required to satisfy the following law:
845− -- | - Associativity: `(x <> y) <> z = x <> (y <> z)`
847− -- | For example, the `String` type is an instance of `Semigroup`, where `(<>)` is defined to be string concatenation.
848− class Semigroup a where
851− foreign import concatString
853− function concatString(s1) {
854− return function(s2) {
858− """ :: String -> String -> String
860− instance semigroupUnit :: Semigroup Unit where
861− (<>) (Unit {}) (Unit {}) = Unit {}
863− instance semigroupString :: Semigroup String where
866− instance semigroupArr :: (Semigroup s') => Semigroup (s -> s') where
867− (<>) f g = \x -> f x <> g x
871− -- | `(++)` is an alias for `(<>)`.
872− (++) :: forall s. (Semigroup s) => s -> s -> s
875 infixl 10 .&.
877 infixl 10 .&.
876 infixl 10 .|.
878 infixl 10 .|.
877 infixl 10 .^.
879 infixl 10 .^.
@@ -886,56 +888,65 @@ module Prelude
886 zshr :: b -> Number -> b
888 zshr :: b -> Number -> b
887 complement :: b -> b
889 complement :: b -> b
891+ instance bitsNumber :: Bits Number where
898+ complement = numComplement
889− foreign import numShl
900+ foreign import numAnd
891− function numShl(n1) {
902+ function numAnd(n1) {
892 return function(n2) {
903 return function(n2) {
893− return n1 << n2;
904+ return n1 & n2;
896 """ :: Number -> Number -> Number
907 """ :: Number -> Number -> Number
898− foreign import numShr
909+ foreign import numOr
900− function numShr(n1) {
911+ function numOr(n1) {
901 return function(n2) {
912 return function(n2) {
902− return n1 >> n2;
913+ return n1 | n2;
905 """ :: Number -> Number -> Number
916 """ :: Number -> Number -> Number
907− foreign import numZshr
918+ foreign import numXor
909− function numZshr(n1) {
920+ function numXor(n1) {
910 return function(n2) {
921 return function(n2) {
911− return n1 >>> n2;
922+ return n1 ^ n2;
914 """ :: Number -> Number -> Number
925 """ :: Number -> Number -> Number
916− foreign import numAnd
927+ foreign import numShl
918− function numAnd(n1) {
929+ function numShl(n1) {
919 return function(n2) {
930 return function(n2) {
920− return n1 & n2;
931+ return n1 << n2;
923 """ :: Number -> Number -> Number
934 """ :: Number -> Number -> Number
925− foreign import numOr
936+ foreign import numShr
927− function numOr(n1) {
938+ function numShr(n1) {
928 return function(n2) {
939 return function(n2) {
929− return n1 | n2;
940+ return n1 >> n2;
932 """ :: Number -> Number -> Number
943 """ :: Number -> Number -> Number
934− foreign import numXor
945+ foreign import numZshr
936− function numXor(n1) {
947+ function numZshr(n1) {
937 return function(n2) {
948 return function(n2) {
938− return n1 ^ n2;
949+ return n1 >>> n2;
941 """ :: Number -> Number -> Number
952 """ :: Number -> Number -> Number
@@ -947,15 +958,6 @@ module Prelude
948 """ :: Number -> Number
959 """ :: Number -> Number
950− instance bitsNumber :: Bits Number where
957− complement = numComplement
959module Data.Function where
961module Data.Function where
961 -- | The `on` function is used to change the domain of a binary operator.
963 -- | The `on` function is used to change the domain of a binary operator.