@@ -1,3 +1,8 @@
1+-- | This snapshot is provided for the purposes of running the test suite.
2+-- | It is not necessarily kept up to date with the official PureScript Prelude,
3+-- | and should not be used in user code.
4+-- | The official Prelude can be found at https://github.com/purescript/purescript-prelude
1module Prelude
6module Prelude
2 ( Unit(..), unit
7 ( Unit(..), unit
@@ -30,99 +35,32 @@ module Prelude
30 , Show, show
35 , Show, show
33− -- | The `Unit` type has a single inhabitant, called `unit`. It represents
34− -- | values with no computational content.
36− -- | `Unit` is often used, wrapped in a monadic type constructor, as the
37− -- | return type of a computation where only
38− -- | the _effects_ are important.
39 newtype Unit = Unit {}
38 newtype Unit = Unit {}
41− -- | `unit` is the sole inhabitant of the `Unit` type.
42 unit :: Unit
40 unit :: Unit
43 unit = Unit {}
41 unit = Unit {}
45 infixr 0 $
43 infixr 0 $
46 infixl 0 #
44 infixl 0 #
48− -- | Applies a function to its argument.
51− -- | length $ groupBy productCategory $ filter isInStock $ products
54− -- | is equivalent to:
57− -- | length (groupBy productCategory (filter isInStock products))
60− -- | `($)` is different from [`(#)`](#-2) because it is right-infix instead of
61− -- | left: `a $ b $ c $ d x = a $ (b $ (c $ (d $ x))) = a (b (c (d x)))`
62 ($) :: forall a b. (a -> b) -> a -> b
46 ($) :: forall a b. (a -> b) -> a -> b
63 ($) f x = f x
47 ($) f x = f x
65− -- | Applies an argument to a function.
68− -- | products # filter isInStock # groupBy productCategory # length
71− -- | is equivalent to:
74− -- | length (groupBy productCategory (filter isInStock products))
77− -- | `(#)` is different from [`($)`](#-1) because it is left-infix instead of
78− -- | right: `x # a # b # c # d = (((x # a) # b) # c) # d = d (c (b (a x)))`
79 (#) :: forall a b. a -> (a -> b) -> b
49 (#) :: forall a b. a -> (a -> b) -> b
80 (#) x f = f x
50 (#) x f = f x
82− -- | Flips the order of the arguments to a function of two arguments.
85− -- | flip const 1 2 = const 2 1 = 2
87 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
52 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
88 flip f b a = f a b
53 flip f b a = f a b
90− -- | Returns its first argument and ignores its second.
93− -- | const 1 "hello" = 1
95 const :: forall a b. a -> b -> a
55 const :: forall a b. a -> b -> a
96 const a _ = a
56 const a _ = a
98− -- | This function returns its first argument, and can be used to assert type
99− -- | equalities. This can be useful when types are otherwise ambiguous.
102− -- | main = print $ [] `asTypeOf` [0]
105− -- | If instead, we had written `main = print []`, the type of the argument
106− -- | `[]` would have been ambiguous, resulting in a compile-time error.
107 asTypeOf :: forall a. a -> a -> a
58 asTypeOf :: forall a. a -> a -> a
108 asTypeOf x _ = x
59 asTypeOf x _ = x
110− -- | An alias for `true`, which can be useful in guard clauses:
113− -- | max x y | x >= y = x
114− -- | | otherwise = y
116 otherwise :: Boolean
61 otherwise :: Boolean
117 otherwise = true
62 otherwise = true
119− -- | Attaches an element to the front of an array, creating a new array.
122− -- | cons 1 [2, 3, 4] = [1, 2, 3, 4]
125− -- | Note, the running time of this function is `O(n)`.
126 foreign import cons
64 foreign import cons
128 function cons(e) {
66 function cons(e) {
@@ -134,42 +72,21 @@ module Prelude
135 infixr 6 :
73 infixr 6 :
137− -- | An infix alias for `cons`.
139− -- | Note, the running time of this function is `O(n)`.
140 (:) :: forall a. a -> [a] -> [a]
75 (:) :: forall a. a -> [a] -> [a]
141 (:) = cons
76 (:) = cons
143 infixr 9 >>>
78 infixr 9 >>>
144 infixr 9 <<<
79 infixr 9 <<<
146− -- | A `Semigroupoid` is similar to a [`Category`](#category) but does not
147− -- | require an identity element `id`, just composable morphisms.
149− -- | `Semigroupoid`s must satisfy the following law:
151− -- | - Associativity: `p <<< (q <<< r) = (p <<< q) <<< r`
153− -- | One example of a `Semigroupoid` is the function type constructor `(->)`,
154− -- | with `(<<<)` defined as function composition.
155 class Semigroupoid a where
81 class Semigroupoid a where
156 (<<<) :: forall b c d. a c d -> a b c -> a b d
82 (<<<) :: forall b c d. a c d -> a b c -> a b d
158 instance semigroupoidArr :: Semigroupoid (->) where
84 instance semigroupoidArr :: Semigroupoid (->) where
159 (<<<) f g x = f (g x)
85 (<<<) f g x = f (g x)
161− -- | Forwards composition, or `(<<<)` with its arguments reversed.
162 (>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d
87 (>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d
163 (>>>) f g = g <<< f
88 (>>>) f g = g <<< f
165− -- | `Category`s consist of objects and composable morphisms between them, and
166− -- | as such are [`Semigroupoids`](#semigroupoid), but unlike `semigroupoids`
167− -- | must have an identity element.
169− -- | Instances must satisfy the following law in addition to the
170− -- | `Semigroupoid` law:
172− -- | - Identity: `id <<< p = p <<< id = p`
173 class (Semigroupoid a) <= Category a where
90 class (Semigroupoid a) <= Category a where
174 id :: forall t. a t t
91 id :: forall t. a t t
@@ -179,194 +96,55 @@ module Prelude
179 infixl 4 <$>
96 infixl 4 <$>
180 infixl 1 <#>
97 infixl 1 <#>
182− -- | A `Functor` is a type constructor which supports a mapping operation
185− -- | `(<$>)` can be used to turn functions `a -> b` into functions
186− -- | `f a -> f b` whose argument and return types use the type constructor `f`
187− -- | to represent some computational context.
189− -- | Instances must satisfy the following laws:
191− -- | - Identity: `(<$>) id = id`
192− -- | - Composition: `(<$>) (f <<< g) = (f <$>) <<< (g <$>)`
193 class Functor f where
99 class Functor f where
194 (<$>) :: forall a b. (a -> b) -> f a -> f b
100 (<$>) :: forall a b. (a -> b) -> f a -> f b
196 instance functorArr :: Functor ((->) r) where
102 instance functorArr :: Functor ((->) r) where
197 (<$>) = (<<<)
103 (<$>) = (<<<)
199− -- | `(<#>)` is `(<$>)` with its arguments reversed. For example:
202− -- | [1, 2, 3] <#> \n -> n * n
204 (<#>) :: forall f a b. (Functor f) => f a -> (a -> b) -> f b
105 (<#>) :: forall f a b. (Functor f) => f a -> (a -> b) -> f b
205 (<#>) fa f = f <$> fa
106 (<#>) fa f = f <$> fa
207− -- | The `void` function is used to ignore the type wrapped by a
208− -- | [`Functor`](#functor), replacing it with `Unit` and keeping only the type
209− -- | information provided by the type constructor itself.
211− -- | `void` is often useful when using `do` notation to change the return type
212− -- | of a monadic computation:
215− -- | main = forE 1 10 \n -> void do
219 void :: forall f a. (Functor f) => f a -> f Unit
108 void :: forall f a. (Functor f) => f a -> f Unit
220 void fa = const unit <$> fa
109 void fa = const unit <$> fa
222 infixl 4 <*>
111 infixl 4 <*>
224− -- | The `Apply` class provides the `(<*>)` which is used to apply a function
225− -- | to an argument under a type constructor.
227− -- | `Apply` can be used to lift functions of two or more arguments to work on
228− -- | values wrapped with the type constructor `f`. It might also be understood
229− -- | in terms of the `lift2` function:
232− -- | lift2 :: forall f a b c. (Apply f) => (a -> b -> c) -> f a -> f b -> f c
233− -- | lift2 f a b = f <$> a <*> b
236− -- | `(<*>)` is recovered from `lift2` as `lift2 ($)`. That is, `(<*>)` lifts
237− -- | the function application operator `($)` to arguments wrapped with the
238− -- | type constructor `f`.
240− -- | Instances must satisfy the following law in addition to the `Functor`
243− -- | - Associative composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`
245− -- | Formally, `Apply` represents a strong lax semi-monoidal endofunctor.
246 class (Functor f) <= Apply f where
113 class (Functor f) <= Apply f where
247 (<*>) :: forall a b. f (a -> b) -> f a -> f b
114 (<*>) :: forall a b. f (a -> b) -> f a -> f b
249 instance applyArr :: Apply ((->) r) where
116 instance applyArr :: Apply ((->) r) where
250 (<*>) f g x = f x (g x)
117 (<*>) f g x = f x (g x)
252− -- | The `Applicative` type class extends the [`Apply`](#apply) type class
253− -- | with a `pure` function, which can be used to create values of type `f a`
254− -- | from values of type `a`.
256− -- | Where [`Apply`](#apply) provides the ability to lift functions of two or
257− -- | more arguments to functions whose arguments are wrapped using `f`, and
258− -- | [`Functor`](#functor) provides the ability to lift functions of one
259− -- | argument, `pure` can be seen as the function which lifts functions of
260− -- | _zero_ arguments. That is, `Applicative` functors support a lifting
261− -- | operation for any number of function arguments.
263− -- | Instances must satisfy the following laws in addition to the `Apply`
266− -- | - Identity: `(pure id) <*> v = v`
267− -- | - Composition: `(pure <<<) <*> f <*> g <*> h = f <*> (g <*> h)`
268− -- | - Homomorphism: `(pure f) <*> (pure x) = pure (f x)`
269− -- | - Interchange: `u <*> (pure y) = (pure ($ y)) <*> u`
270 class (Apply f) <= Applicative f where
119 class (Apply f) <= Applicative f where
271 pure :: forall a. a -> f a
120 pure :: forall a. a -> f a
273 instance applicativeArr :: Applicative ((->) r) where
122 instance applicativeArr :: Applicative ((->) r) where
274 pure = const
123 pure = const
276− -- | `return` is an alias for `pure`.
277 return :: forall m a. (Applicative m) => a -> m a
125 return :: forall m a. (Applicative m) => a -> m a
278 return = pure
126 return = pure
280− -- | `liftA1` provides a default implementation of `(<$>)` for any
281− -- | [`Applicative`](#applicative) functor, without using `(<$>)` as provided
282− -- | by the [`Functor`](#functor)-[`Applicative`](#applicative) superclass
285− -- | `liftA1` can therefore be used to write [`Functor`](#functor) instances
289− -- | instance functorF :: Functor F where
292 liftA1 :: forall f a b. (Applicative f) => (a -> b) -> f a -> f b
128 liftA1 :: forall f a b. (Applicative f) => (a -> b) -> f a -> f b
293 liftA1 f a = pure f <*> a
129 liftA1 f a = pure f <*> a
295 infixl 1 >>=
131 infixl 1 >>=
297− -- | The `Bind` type class extends the [`Apply`](#apply) type class with a
298− -- | "bind" operation `(>>=)` which composes computations in sequence, using
299− -- | the return value of one computation to determine the next computation.
301− -- | The `>>=` operator can also be expressed using `do` notation, as follows:
304− -- | x >>= f = do y <- x
308− -- | where the function argument of `f` is given the name `y`.
310− -- | Instances must satisfy the following law in addition to the `Apply`
313− -- | - Associativity: `(x >>= f) >>= g = x >>= (\k => f k >>= g)`
315− -- | Associativity tells us that we can regroup operations which use `do`
316− -- | notation so that we can unambiguously write, for example:
323 class (Apply m) <= Bind m where
133 class (Apply m) <= Bind m where
324 (>>=) :: forall a b. m a -> (a -> m b) -> m b
134 (>>=) :: forall a b. m a -> (a -> m b) -> m b
326 instance bindArr :: Bind ((->) r) where
136 instance bindArr :: Bind ((->) r) where
327 (>>=) m f x = f (m x) x
137 (>>=) m f x = f (m x) x
329− -- | The `Monad` type class combines the operations of the `Bind` and
330− -- | `Applicative` type classes. Therefore, `Monad` instances represent type
331− -- | constructors which support sequential composition, and also lifting of
332− -- | functions of arbitrary arity.
334− -- | Instances must satisfy the following laws in addition to the
335− -- | `Applicative` and `Bind` laws:
337− -- | - Left Identity: `pure x >>= f = f x`
338− -- | - Right Identity: `x >>= pure = x`
339 class (Applicative m, Bind m) <= Monad m
139 class (Applicative m, Bind m) <= Monad m
341 instance monadArr :: Monad ((->) r)
141 instance monadArr :: Monad ((->) r)
343− -- | `liftM1` provides a default implementation of `(<$>)` for any
344− -- | [`Monad`](#monad), without using `(<$>)` as provided by the
345− -- | [`Functor`](#functor)-[`Monad`](#monad) superclass relationship.
347− -- | `liftM1` can therefore be used to write [`Functor`](#functor) instances
351− -- | instance functorF :: Functor F where
354 liftM1 :: forall m a b. (Monad m) => (a -> b) -> m a -> m b
143 liftM1 :: forall m a b. (Monad m) => (a -> b) -> m a -> m b
355 liftM1 f a = do
144 liftM1 f a = do
357 return (f a')
146 return (f a')
359− -- | `ap` provides a default implementation of `(<*>)` for any
360− -- | [`Monad`](#monad), without using `(<*>)` as provided by the
361− -- | [`Apply`](#apply)-[`Monad`](#monad) superclass relationship.
363− -- | `ap` can therefore be used to write [`Apply`](#apply) instances as
367− -- | instance applyF :: Apply F where
370 ap :: forall m a b. (Monad m) => m (a -> b) -> m a -> m b
148 ap :: forall m a b. (Monad m) => m (a -> b) -> m a -> m b
371 ap f a = do
149 ap f a = do
@@ -376,18 +154,9 @@ module Prelude
376 infixr 5 <>
154 infixr 5 <>
377 infixr 5 ++
155 infixr 5 ++
379− -- | The `Semigroup` type class identifies an associative operation on a type.
381− -- | Instances are required to satisfy the following law:
383− -- | - Associativity: `(x <> y) <> z = x <> (y <> z)`
385− -- | One example of a `Semigroup` is `String`, with `(<>)` defined as string
387 class Semigroup a where
157 class Semigroup a where
388 (<>) :: a -> a -> a
158 (<>) :: a -> a -> a
390− -- | `(++)` is an alias for `(<>)`.
391 (++) :: forall s. (Semigroup s) => s -> s -> s
160 (++) :: forall s. (Semigroup s) => s -> s -> s
392 (++) = (<>)
161 (++) = (<>)
@@ -417,22 +186,6 @@ module Prelude
417 infixl 6 +
186 infixl 6 +
418 infixl 7 *
187 infixl 7 *
420− -- | The `Semiring` class is for types that support an addition and
421− -- | multiplication operation.
423− -- | Instances must satisfy the following laws:
425− -- | - Commutative monoid under addition:
426− -- | - Associativity: `(a + b) + c = a + (b + c)`
427− -- | - Identity: `zero + a = a + zero = a`
428− -- | - Commutative: `a + b = b + a`
429− -- | - Monoid under multiplication:
430− -- | - Associativity: `(a * b) * c = a * (b * c)`
431− -- | - Identity: `one * a = a * one = a`
432− -- | - Multiplication distributes over addition:
433− -- | - Left distributivity: `a * (b + c) = (a * b) + (a * c)`
434− -- | - Right distributivity: `(a + b) * c = (a * c) + (b * c)`
435− -- | - Annihiliation: `zero * a = a * zero = zero`
436 class Semiring a where
189 class Semiring a where
437 (+) :: a -> a -> a
190 (+) :: a -> a -> a
438 zero :: a
191 zero :: a
@@ -453,13 +206,6 @@ module Prelude
454 infixl 6 -
207 infixl 6 -
456− -- | The `Ring` class is for types that support addition, multiplication,
457− -- | and subtraction operations.
459− -- | Instances must satisfy the following law in addition to the `Semiring`
462− -- | - Additive inverse: `a + (-a) = (-a) + a = zero`
463 class (Semiring a) <= Ring a where
209 class (Semiring a) <= Ring a where
464 (-) :: a -> a -> a
210 (-) :: a -> a -> a
@@ -474,13 +220,6 @@ module Prelude
475 infixl 7 /
221 infixl 7 /
477− -- | The `ModuloSemiring` class is for types that support addition,
478− -- | multiplication, division, and modulo (division remainder) operations.
480− -- | Instances must satisfy the following law in addition to the `Semiring`
483− -- | - Remainder: `a / b * b + (a `mod` b) = a`
484 class (Semiring a) <= ModuloSemiring a where
223 class (Semiring a) <= ModuloSemiring a where
485 (/) :: a -> a -> a
224 (/) :: a -> a -> a
486 mod :: a -> a -> a
225 mod :: a -> a -> a
@@ -493,27 +232,12 @@ module Prelude
493 (/) _ _ = unit
232 (/) _ _ = unit
494 mod _ _ = unit
233 mod _ _ = unit
496− -- | A `Ring` where every nonzero element has a multiplicative inverse.
498− -- | Instances must satisfy the following law in addition to the `Ring` and
499− -- | `ModuloSemiring` laws:
501− -- | - Multiplicative inverse: `(one / x) * x = one`
503− -- | As a consequence of this ```a `mod` b = zero``` as no divide operation
504− -- | will have a remainder.
505 class (Ring a, ModuloSemiring a) <= DivisionRing a
235 class (Ring a, ModuloSemiring a) <= DivisionRing a
507 instance divisionRingNumber :: DivisionRing Number
237 instance divisionRingNumber :: DivisionRing Number
509 instance divisionRingUnit :: DivisionRing Unit
239 instance divisionRingUnit :: DivisionRing Unit
511− -- | The `Num` class is for types that are commutative fields.
513− -- | Instances must satisfy the following law in addition to the
514− -- | `DivisionRing` laws:
516− -- | - Commutative multiplication: `a * b = b * a`
517 class (DivisionRing a) <= Num a
241 class (DivisionRing a) <= Num a
519 instance numNumber :: Num Number
243 instance numNumber :: Num Number
@@ -559,16 +283,6 @@ module Prelude
559 infix 4 ==
283 infix 4 ==
560 infix 4 /=
284 infix 4 /=
562− -- | The `Eq` type class represents types which support decidable equality.
564− -- | `Eq` instances should satisfy the following laws:
566− -- | - Reflexivity: `x == x = true`
567− -- | - Symmetry: `x == y = y == x`
568− -- | - Transitivity: if `x == y` and `y == z` then `x == z`
569− -- | - Negation: `x /= y = not (x == y)`
571− -- | `(/=)` may be implemented in terms of `(==)`, but it might give a performance improvement to implement it separately.
572 class Eq a where
286 class Eq a where
573 (==) :: a -> a -> Boolean
287 (==) :: a -> a -> Boolean
574 (/=) :: a -> a -> Boolean
288 (/=) :: a -> a -> Boolean
@@ -633,21 +347,8 @@ module Prelude
634 """ :: forall a. (a -> a -> Boolean) -> [a] -> [a] -> Boolean
348 """ :: forall a. (a -> a -> Boolean) -> [a] -> [a] -> Boolean
636− -- | The `Ordering` data type represents the three possible outcomes of
637− -- | comparing two values:
639− -- | `LT` - The first value is _less than_ the second.
640− -- | `GT` - The first value is _greater than_ the second.
641− -- | `EQ` - The first value is _equal to_ or _incomparable to_ the second.
642 data Ordering = LT | GT | EQ
350 data Ordering = LT | GT | EQ
644− -- | The `Ord` type class represents types which support comparisons.
646− -- | `Ord` instances should satisfy the laws of _partially orderings_:
648− -- | - Reflexivity: `a <= a`
649− -- | - Antisymmetry: if `a <= b` and `b <= a` then `a = b`
650− -- | - Transitivity: if `a <= b` and `b <= c` then `a <= c`
651 class (Eq a) <= Ord a where
352 class (Eq a) <= Ord a where
652 compare :: a -> a -> Ordering
353 compare :: a -> a -> Ordering
@@ -688,25 +389,21 @@ module Prelude
688 infixl 4 <=
389 infixl 4 <=
689 infixl 4 >=
390 infixl 4 >=
691− -- | Test whether one value is _strictly less than_ another.
692 (<) :: forall a. (Ord a) => a -> a -> Boolean
392 (<) :: forall a. (Ord a) => a -> a -> Boolean
693 (<) a1 a2 = case a1 `compare` a2 of
393 (<) a1 a2 = case a1 `compare` a2 of
694 LT -> true
394 LT -> true
695 _ -> false
395 _ -> false
697− -- | Test whether one value is _strictly greater than_ another.
698 (>) :: forall a. (Ord a) => a -> a -> Boolean
397 (>) :: forall a. (Ord a) => a -> a -> Boolean
699 (>) a1 a2 = case a1 `compare` a2 of
398 (>) a1 a2 = case a1 `compare` a2 of
700 GT -> true
399 GT -> true
701 _ -> false
400 _ -> false
703− -- | Test whether one value is _non-strictly less than_ another.
704 (<=) :: forall a. (Ord a) => a -> a -> Boolean
402 (<=) :: forall a. (Ord a) => a -> a -> Boolean
705 (<=) a1 a2 = case a1 `compare` a2 of
403 (<=) a1 a2 = case a1 `compare` a2 of
706 GT -> false
404 GT -> false
707 _ -> true
405 _ -> true
709− -- | Test whether one value is _non-strictly greater than_ another.
710 (>=) :: forall a. (Ord a) => a -> a -> Boolean
407 (>=) :: forall a. (Ord a) => a -> a -> Boolean
711 (>=) a1 a2 = case a1 `compare` a2 of
408 (>=) a1 a2 = case a1 `compare` a2 of
712 LT -> false
409 LT -> false
@@ -730,12 +427,6 @@ module Prelude
731 """ :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
428 """ :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
733− -- | The `Bounded` type class represents types that are finite partially
736− -- | Instances should satisfy the following law in addition to the `Ord` laws:
738− -- | - Ordering: `bottom <= a <= top`
739 class (Ord a) <= Bounded a where
430 class (Ord a) <= Bounded a where
741 bottom :: a
432 bottom :: a
@@ -752,24 +443,6 @@ module Prelude
753 bottom = LT
444 bottom = LT
755− -- | The `Lattice` type class represents types that are partially ordered
756− -- | sets with a supremum (`sup` or `||`) and infimum (`inf` or `&&`).
758− -- | Instances should satisfy the following laws in addition to the `Ord`
761− -- | - Associativity:
762− -- | - `a || (b || c) = (a || b) || c`
763− -- | - `a && (b && c) = (a && b) && c`
764− -- | - Commutativity:
765− -- | - `a || b = b || a`
766− -- | - `a && b = b && a`
768− -- | - `a || (a && b) = a`
769− -- | - `a && (a || b) = a`
773 class (Ord a) <= Lattice a where
446 class (Ord a) <= Lattice a where
774 sup :: a -> a -> a
447 sup :: a -> a -> a
775 inf :: a -> a -> a
448 inf :: a -> a -> a
@@ -785,43 +458,18 @@ module Prelude
785 infixr 2 ||
458 infixr 2 ||
786 infixr 3 &&
459 infixr 3 &&
788− -- | The `sup` operator.
789 (||) :: forall a. (Lattice a) => a -> a -> a
461 (||) :: forall a. (Lattice a) => a -> a -> a
790 (||) = sup
462 (||) = sup
792− -- | The `inf` operator.
793 (&&) :: forall a. (Lattice a) => a -> a -> a
464 (&&) :: forall a. (Lattice a) => a -> a -> a
794 (&&) = inf
465 (&&) = inf
796− -- | The `BoundedLattice` type class represents types that are finite
799− -- | Instances should satisfy the following law in addition to the `Lattice`
800− -- | and `Bounded` laws:
803− -- | - `a || bottom = a`
804− -- | - `a && top = a`
805− -- | - Annihiliation:
806− -- | - `a || top = top`
807− -- | - `a && bottom = bottom`
808 class (Bounded a, Lattice a) <= BoundedLattice a
467 class (Bounded a, Lattice a) <= BoundedLattice a
810 instance boundedLatticeBoolean :: BoundedLattice Boolean
469 instance boundedLatticeBoolean :: BoundedLattice Boolean
812 instance boundedLatticeUnit :: BoundedLattice Unit
471 instance boundedLatticeUnit :: BoundedLattice Unit
814− -- | The `ComplementedLattice` type class represents types that are lattices
815− -- | where every member is also uniquely complemented.
817− -- | Instances should satisfy the following law in addition to the
818− -- | `BoundedLattice` laws:
820− -- | - Complemented:
821− -- | - `not a || a == top`
822− -- | - `not a && a == bottom`
823− -- | - Double negation:
824− -- | - `not <<< not == id`
825 class (BoundedLattice a) <= ComplementedLattice a where
473 class (BoundedLattice a) <= ComplementedLattice a where
826 not :: a -> a
474 not :: a -> a
@@ -831,24 +479,12 @@ module Prelude
831 instance complementedLatticeUnit :: ComplementedLattice Unit where
479 instance complementedLatticeUnit :: ComplementedLattice Unit where
832 not _ = unit
480 not _ = unit
834− -- | The `DistributiveLattice` type class represents types that are lattices
835− -- | where the `&&` and `||` distribute over each other.
837− -- | Instances should satisfy the following law in addition to the `Lattice`
840− -- | - Distributivity: `x && (y || z) = (x && y) || (x && z)`
841 class (Lattice a) <= DistributiveLattice a
482 class (Lattice a) <= DistributiveLattice a
843 instance distributiveLatticeBoolean :: DistributiveLattice Boolean
484 instance distributiveLatticeBoolean :: DistributiveLattice Boolean
845 instance distributiveLatticeUnit :: DistributiveLattice Unit
486 instance distributiveLatticeUnit :: DistributiveLattice Unit
847− -- | The `BooleanAlgebra` type class represents types that are Boolean
848− -- | algebras, also known as Boolean lattices.
850− -- | Instances should satisfy the `ComplementedLattice` and
851− -- | `DistributiveLattice` laws.
852 class (ComplementedLattice a, DistributiveLattice a) <= BooleanAlgebra a
488 class (ComplementedLattice a, DistributiveLattice a) <= BooleanAlgebra a
854 instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
490 instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
@@ -880,12 +516,6 @@ module Prelude
881 """ :: Boolean -> Boolean
517 """ :: Boolean -> Boolean
883− -- | The `Show` type class represents those types which can be converted into
884− -- | a human-readable `String` representation.
886− -- | While not required, it is recommended that for any expression `x`, the
887− -- | string `show x` be executable PureScript code which evaluates to the same
888− -- | value as the expression `x`.
889 class Show a where
519 class Show a where
890 show :: a -> String
520 show :: a -> String
@@ -939,51 +569,31 @@ module Prelude
940module Data.Function where
570module Data.Function where
942− -- | The `on` function is used to change the domain of a binary operator.
944− -- | For example, we can create a function which compares two records based on the values of their `x` properties:
947− -- | compareX :: forall r. { x :: Number | r } -> { x :: Number | r } -> Ordering
948− -- | compareX = compare `on` _.x
950 on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
572 on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
951 on f g x y = g x `f` g y
573 on f g x y = g x `f` g y
953− -- | A function of zero arguments
954 foreign import data Fn0 :: * -> *
575 foreign import data Fn0 :: * -> *
956− -- | A function of one argument
957 foreign import data Fn1 :: * -> * -> *
577 foreign import data Fn1 :: * -> * -> *
959− -- | A function of two arguments
960 foreign import data Fn2 :: * -> * -> * -> *
579 foreign import data Fn2 :: * -> * -> * -> *
962− -- | A function of three arguments
963 foreign import data Fn3 :: * -> * -> * -> * -> *
581 foreign import data Fn3 :: * -> * -> * -> * -> *
965− -- | A function of four arguments
966 foreign import data Fn4 :: * -> * -> * -> * -> * -> *
583 foreign import data Fn4 :: * -> * -> * -> * -> * -> *
968− -- | A function of five arguments
969 foreign import data Fn5 :: * -> * -> * -> * -> * -> * -> *
585 foreign import data Fn5 :: * -> * -> * -> * -> * -> * -> *
971− -- | A function of six arguments
972 foreign import data Fn6 :: * -> * -> * -> * -> * -> * -> * -> *
587 foreign import data Fn6 :: * -> * -> * -> * -> * -> * -> * -> *
974− -- | A function of seven arguments
975 foreign import data Fn7 :: * -> * -> * -> * -> * -> * -> * -> * -> *
589 foreign import data Fn7 :: * -> * -> * -> * -> * -> * -> * -> * -> *
977− -- | A function of eight arguments
978 foreign import data Fn8 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> *
591 foreign import data Fn8 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> *
980− -- | A function of nine arguments
981 foreign import data Fn9 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
593 foreign import data Fn9 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
983− -- | A function of ten arguments
984 foreign import data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
595 foreign import data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
986− -- | Create a function of no arguments
987 foreign import mkFn0
597 foreign import mkFn0
989 function mkFn0(fn) {
599 function mkFn0(fn) {
@@ -993,7 +603,6 @@ module Data.Function where
994 """ :: forall a. (Unit -> a) -> Fn0 a
604 """ :: forall a. (Unit -> a) -> Fn0 a
996− -- | Create a function of one argument
997 foreign import mkFn1
606 foreign import mkFn1
999 function mkFn1(fn) {
608 function mkFn1(fn) {
@@ -1003,7 +612,6 @@ module Data.Function where
1004 """ :: forall a b. (a -> b) -> Fn1 a b
613 """ :: forall a b. (a -> b) -> Fn1 a b
1006− -- | Create a function of two arguments from a curried function
1007 foreign import mkFn2
615 foreign import mkFn2
1009 function mkFn2(fn) {
617 function mkFn2(fn) {
@@ -1013,7 +621,6 @@ module Data.Function where
1014 """ :: forall a b c. (a -> b -> c) -> Fn2 a b c
622 """ :: forall a b c. (a -> b -> c) -> Fn2 a b c
1016− -- | Create a function of three arguments from a curried function
1017 foreign import mkFn3
624 foreign import mkFn3
1019 function mkFn3(fn) {
626 function mkFn3(fn) {
@@ -1023,7 +630,6 @@ module Data.Function where
1024 """ :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d
631 """ :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d
1026− -- | Create a function of four arguments from a curried function
1027 foreign import mkFn4
633 foreign import mkFn4
1029 function mkFn4(fn) {
635 function mkFn4(fn) {
@@ -1033,7 +639,6 @@ module Data.Function where
1034 """ :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e
640 """ :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e
1036− -- | Create a function of five arguments from a curried function
1037 foreign import mkFn5
642 foreign import mkFn5
1039 function mkFn5(fn) {
644 function mkFn5(fn) {
@@ -1043,7 +648,6 @@ module Data.Function where
1044 """ :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f
649 """ :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f
1046− -- | Create a function of six arguments from a curried function
1047 foreign import mkFn6
651 foreign import mkFn6
1049 function mkFn6(fn) {
653 function mkFn6(fn) {
@@ -1053,7 +657,6 @@ module Data.Function where
1054 """ :: forall a b c d e f g. (a -> b -> c -> d -> e -> f -> g) -> Fn6 a b c d e f g
658 """ :: forall a b c d e f g. (a -> b -> c -> d -> e -> f -> g) -> Fn6 a b c d e f g
1056− -- | Create a function of seven arguments from a curried function
1057 foreign import mkFn7
660 foreign import mkFn7
1059 function mkFn7(fn) {
662 function mkFn7(fn) {
@@ -1063,7 +666,6 @@ module Data.Function where
1064 """ :: forall a b c d e f g h. (a -> b -> c -> d -> e -> f -> g -> h) -> Fn7 a b c d e f g h
667 """ :: forall a b c d e f g h. (a -> b -> c -> d -> e -> f -> g -> h) -> Fn7 a b c d e f g h
1066− -- | Create a function of eight arguments from a curried function
1067 foreign import mkFn8
669 foreign import mkFn8
1069 function mkFn8(fn) {
671 function mkFn8(fn) {
@@ -1073,7 +675,6 @@ module Data.Function where
1074 """ :: forall a b c d e f g h i. (a -> b -> c -> d -> e -> f -> g -> h -> i) -> Fn8 a b c d e f g h i
676 """ :: forall a b c d e f g h i. (a -> b -> c -> d -> e -> f -> g -> h -> i) -> Fn8 a b c d e f g h i
1076− -- | Create a function of nine arguments from a curried function
1077 foreign import mkFn9
678 foreign import mkFn9
1079 function mkFn9(fn) {
680 function mkFn9(fn) {
@@ -1083,7 +684,6 @@ module Data.Function where
1084 """ :: forall a b c d e f g h i j. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> Fn9 a b c d e f g h i j
685 """ :: forall a b c d e f g h i j. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> Fn9 a b c d e f g h i j
1086− -- | Create a function of ten arguments from a curried function
1087 foreign import mkFn10
687 foreign import mkFn10
1089 function mkFn10(fn) {
689 function mkFn10(fn) {
@@ -1093,7 +693,6 @@ module Data.Function where
1094 """ :: forall a b c d e f g h i j k. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> Fn10 a b c d e f g h i j k
694 """ :: forall a b c d e f g h i j k. (a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k) -> Fn10 a b c d e f g h i j k
1096− -- | Apply a function of no arguments
1097 foreign import runFn0
696 foreign import runFn0
1099 function runFn0(fn) {
698 function runFn0(fn) {
@@ -1101,7 +700,6 @@ module Data.Function where
1102 """ :: forall a. Fn0 a -> a
701 """ :: forall a. Fn0 a -> a
1104− -- | Apply a function of one argument
1105 foreign import runFn1
703 foreign import runFn1
1107 function runFn1(fn) {
705 function runFn1(fn) {
@@ -1111,7 +709,6 @@ module Data.Function where
1112 """ :: forall a b. Fn1 a b -> a -> b
710 """ :: forall a b. Fn1 a b -> a -> b
1114− -- | Apply a function of two arguments
1115 foreign import runFn2
712 foreign import runFn2
1117 function runFn2(fn) {
714 function runFn2(fn) {
@@ -1123,7 +720,6 @@ module Data.Function where
1124 """ :: forall a b c. Fn2 a b c -> a -> b -> c
721 """ :: forall a b c. Fn2 a b c -> a -> b -> c
1126− -- | Apply a function of three arguments
1127 foreign import runFn3
723 foreign import runFn3
1129 function runFn3(fn) {
725 function runFn3(fn) {
@@ -1137,7 +733,6 @@ module Data.Function where
1138 """ :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d
734 """ :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d
1140− -- | Apply a function of four arguments
1141 foreign import runFn4
736 foreign import runFn4
1143 function runFn4(fn) {
738 function runFn4(fn) {
@@ -1153,7 +748,6 @@ module Data.Function where
1154 """ :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e
749 """ :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e
1156− -- | Apply a function of five arguments
1157 foreign import runFn5
751 foreign import runFn5
1159 function runFn5(fn) {
753 function runFn5(fn) {
@@ -1171,7 +765,6 @@ module Data.Function where
1172 """ :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f
766 """ :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f
1174− -- | Apply a function of six arguments
1175 foreign import runFn6
768 foreign import runFn6
1177 function runFn6(fn) {
770 function runFn6(fn) {
@@ -1191,7 +784,6 @@ module Data.Function where
1192 """ :: forall a b c d e f g. Fn6 a b c d e f g -> a -> b -> c -> d -> e -> f -> g
785 """ :: forall a b c d e f g. Fn6 a b c d e f g -> a -> b -> c -> d -> e -> f -> g
1194− -- | Apply a function of seven arguments
1195 foreign import runFn7
787 foreign import runFn7
1197 function runFn7(fn) {
789 function runFn7(fn) {
@@ -1213,7 +805,6 @@ module Data.Function where
1214 """ :: forall a b c d e f g h. Fn7 a b c d e f g h -> a -> b -> c -> d -> e -> f -> g -> h
806 """ :: forall a b c d e f g h. Fn7 a b c d e f g h -> a -> b -> c -> d -> e -> f -> g -> h
1216− -- | Apply a function of eight arguments
1217 foreign import runFn8
808 foreign import runFn8
1219 function runFn8(fn) {
810 function runFn8(fn) {
@@ -1237,7 +828,6 @@ module Data.Function where
1238 """ :: forall a b c d e f g h i. Fn8 a b c d e f g h i -> a -> b -> c -> d -> e -> f -> g -> h -> i
829 """ :: forall a b c d e f g h i. Fn8 a b c d e f g h i -> a -> b -> c -> d -> e -> f -> g -> h -> i
1240− -- | Apply a function of nine arguments
1241 foreign import runFn9
831 foreign import runFn9
1243 function runFn9(fn) {
833 function runFn9(fn) {
@@ -1263,7 +853,6 @@ module Data.Function where
1264 """ :: forall a b c d e f g h i j. Fn9 a b c d e f g h i j -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j
854 """ :: forall a b c d e f g h i j. Fn9 a b c d e f g h i j -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j
1266− -- | Apply a function of ten arguments
1267 foreign import runFn10
856 foreign import runFn10
1269 function runFn10(fn) {
858 function runFn10(fn) {
@@ -1293,9 +882,6 @@ module Data.Function where
1294module Prelude.Unsafe where
883module Prelude.Unsafe where
1296− -- | Find the element of an array at the specified index.
1298− -- | Note: this function can cause unpredictable failure at runtime if the index is out-of-bounds.
1299 foreign import unsafeIndex
885 foreign import unsafeIndex
1301 function unsafeIndex(xs) {
887 function unsafeIndex(xs) {
@@ -1309,14 +895,9 @@ module Control.Monad.Eff
1310 , Pure()
896 , Pure()
1311 , runPure
897 , runPure
1312− , untilE, whileE, forE, foreachE
898+ , untilE, whileE
1315− -- | The `Eff` type constructor is used to represent _native_ effects.
1317− -- | See [Handling Native Effects with the Eff Monad](https://github.com/purescript/purescript/wiki/Handling-Native-Effects-with-the-Eff-Monad) for more details.
1319− -- | The first type parameter is a row of effects which represents the contexts in which a computation can be run, and the second type parameter is the return type.
1320 foreign import data Eff :: # ! -> * -> *
901 foreign import data Eff :: # ! -> * -> *
1322 foreign import returnE
903 foreign import returnE
@@ -1339,15 +920,8 @@ module Control.Monad.Eff
1340 """ :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
921 """ :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
1342− -- | The `Pure` type synonym represents _pure_ computations, i.e. ones in which all effects have been handled.
1344− -- | The `runPure` function can be used to run pure computations and obtain their result.
1345 type Pure a = forall e. Eff e a
923 type Pure a = forall e. Eff e a
1347− -- | Run a pure computation and return its result.
1349− -- | Note: since this function has a rank-2 type, it may cause problems to apply this function using the `$` operator. The recommended approach
1350− -- | is to use parentheses instead.
1351 foreign import runPure
925 foreign import runPure
1353 function runPure(f) {
927 function runPure(f) {
@@ -1369,10 +943,6 @@ module Control.Monad.Eff
1370 instance monadEff :: Monad (Eff e)
944 instance monadEff :: Monad (Eff e)
1372− -- | Loop until a condition becomes `true`.
1374− -- | `untilE b` is an effectful computation which repeatedly runs the effectful computation `b`,
1375− -- | until its return value is `true`.
1376 foreign import untilE
946 foreign import untilE
1378 function untilE(f) {
948 function untilE(f) {
@@ -1383,10 +953,6 @@ module Control.Monad.Eff
1384 """ :: forall e. Eff e Boolean -> Eff e Unit
954 """ :: forall e. Eff e Boolean -> Eff e Unit
1386− -- | Loop while a condition is `true`.
1388− -- | `whileE b m` is effectful computation which runs the effectful computation `b`. If its result is
1389− -- | `true`, it runs the effectful computation `m` and loops. If not, the computation ends.
1390 foreign import whileE
956 foreign import whileE
1392 function whileE(f) {
958 function whileE(f) {
@@ -1401,63 +967,12 @@ module Control.Monad.Eff
1402 """ :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
968 """ :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
1404− -- | Loop over a consecutive collection of numbers.
1406− -- | `forE lo hi f` runs the computation returned by the function `f` for each of the inputs
1407− -- | between `lo` (inclusive) and `hi` (exclusive).
1408− foreign import forE
1410− function forE(lo) {
1411− return function(hi) {
1412− return function(f) {
1413− return function() {
1414− for (var i = lo; i < hi; i++) {
1421− """ :: forall e. Number -> Number -> (Number -> Eff e Unit) -> Eff e Unit
1423− -- | Loop over an array of values.
1425− -- | `foreach xs f` runs the computation returned by the function `f` for each of the inputs `xs`.
1426− foreign import foreachE
1428− function foreachE(as) {
1429− return function(f) {
1430− return function() {
1431− for (var i = 0; i < as.length; i++) {
1437− """ :: forall e a. [a] -> (a -> Eff e Unit) -> Eff e Unit
1439−module Control.Monad.Eff.Unsafe where
1441− import Control.Monad.Eff
1443− -- | Change the type of an effectful computation, allowing it to be run in another context.
1445− -- | Note: use of this function can result in arbitrary side-effects.
1446− foreign import unsafeInterleaveEff
1448− function unsafeInterleaveEff(f) {
1451− """ :: forall eff1 eff2 a. Eff eff1 a -> Eff eff2 a
1453module Debug.Trace where
970module Debug.Trace where
1455 import Control.Monad.Eff
972 import Control.Monad.Eff
1457− -- | The `Trace` effect represents those computations which write to the console.
1458 foreign import data Trace :: !
974 foreign import data Trace :: !
1460− -- | Write a `String` to the console.
1461 foreign import trace
976 foreign import trace
1463 function trace(s) {
978 function trace(s) {
@@ -1468,7 +983,6 @@ module Debug.Trace where
1469 """ :: forall r. String -> Eff (trace :: Trace | r) Unit
984 """ :: forall r. String -> Eff (trace :: Trace | r) Unit
1471− -- | Write a value to the console, using its `Show` instance to produce a `String`.
1472 print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit
986 print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit
1473 print o = trace (show o)
987 print o = trace (show o)
@@ -1476,17 +990,10 @@ module Control.Monad.ST where
1477 import Control.Monad.Eff
991 import Control.Monad.Eff
1479− -- | The `ST` effect represents _local mutation_, i.e. mutation which does not "escape" into the surrounding computation.
1481− -- | An `ST` computation is parameterized by a phantom type which is used to restrict the set of reference cells it is allowed to access.
1483− -- | The `runST` function can be used to handle the `ST` effect.
1484 foreign import data ST :: * -> !
993 foreign import data ST :: * -> !
1486− -- | The type `STRef s a` represents a mutable reference holding a value of type `a`, which can be used with the `ST s` effect.
1487 foreign import data STRef :: * -> * -> *
995 foreign import data STRef :: * -> * -> *
1489− -- | Create a new mutable reference.
1490 foreign import newSTRef
997 foreign import newSTRef
1492 function newSTRef(val) {
999 function newSTRef(val) {
@@ -1496,7 +1003,6 @@ module Control.Monad.ST where
1497 """ :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
1004 """ :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
1499− -- | Read the current value of a mutable reference.
1500 foreign import readSTRef
1006 foreign import readSTRef
1502 function readSTRef(ref) {
1008 function readSTRef(ref) {
@@ -1506,7 +1012,6 @@ module Control.Monad.ST where
1507 """ :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
1013 """ :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
1509− -- | Modify the value of a mutable reference by applying a function to the current value.
1510 foreign import modifySTRef
1015 foreign import modifySTRef
1512 function modifySTRef(ref) {
1017 function modifySTRef(ref) {
@@ -1518,7 +1023,6 @@ module Control.Monad.ST where
1519 """ :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
1024 """ :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
1521− -- | Set the value of a mutable reference.
1522 foreign import writeSTRef
1026 foreign import writeSTRef
1524 function writeSTRef(ref) {
1028 function writeSTRef(ref) {
@@ -1530,12 +1034,6 @@ module Control.Monad.ST where
1531 """ :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
1035 """ :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
1533− -- | Run an `ST` computation.
1535− -- | Note: the type of `runST` uses a rank-2 type to constrain the phantom type `s`, such that the computation must not leak any mutable references
1536− -- | to the surrounding computation.
1538− -- | It may cause problems to apply this function using the `$` operator. The recommended approach is to use parentheses instead.
1539 foreign import runST
1037 foreign import runST
1541 function runST(f) {
1039 function runST(f) {
@@ -1543,9 +1041,5 @@ module Control.Monad.ST where
1544 """ :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
1042 """ :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
1546− -- | A convenience function which combines `runST` with `runPure`, which can be used when the only required effect is `ST`.
1548− -- | Note: since this function has a rank-2 type, it may cause problems to apply this function using the `$` operator. The recommended approach
1549− -- | is to use parentheses instead.
1550 pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
1044 pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
1551− pureST st = runPure (runST st)
1045+ pureST st = runPure (runST st)