@@ -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
5+
16module Prelude
27 ( Unit(..), unit
38 , ($), (#)
@@ -30,99 +35,32 @@ module Prelude
3035 , Show, show
3136 ) where
3237
33− -- | The `Unit` type has a single inhabitant, called `unit`. It represents
34− -- | values with no computational content.
35− -- |
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.
3938 newtype Unit = Unit {}
4039
41− -- | `unit` is the sole inhabitant of the `Unit` type.
4240 unit :: Unit
4341 unit = Unit {}
4442
4543 infixr 0 $
4644 infixl 0 #
4745
48− -- | Applies a function to its argument.
49− -- |
50− -- | ```purescript
51− -- | length $ groupBy productCategory $ filter isInStock $ products
52− -- | ```
53− -- |
54− -- | is equivalent to:
55− -- |
56− -- | ```purescript
57− -- | length (groupBy productCategory (filter isInStock products))
58− -- | ```
59− -- |
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)))`
6246 ($) :: forall a b. (a -> b) -> a -> b
6347 ($) f x = f x
6448
65− -- | Applies an argument to a function.
66− -- |
67− -- | ```purescript
68− -- | products # filter isInStock # groupBy productCategory # length
69− -- | ```
70− -- |
71− -- | is equivalent to:
72− -- |
73− -- | ```purescript
74− -- | length (groupBy productCategory (filter isInStock products))
75− -- | ```
76− -- |
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)))`
7949 (#) :: forall a b. a -> (a -> b) -> b
8050 (#) x f = f x
8151
82− -- | Flips the order of the arguments to a function of two arguments.
83− -- |
84− -- | ```purescript
85− -- | flip const 1 2 = const 2 1 = 2
86− -- | ```
8752 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
8853 flip f b a = f a b
8954
90− -- | Returns its first argument and ignores its second.
91− -- |
92− -- | ```purescript
93− -- | const 1 "hello" = 1
94− -- | ```
9555 const :: forall a b. a -> b -> a
9656 const a _ = a
9757
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.
100− -- |
101− -- | ```purescript
102− -- | main = print $ [] `asTypeOf` [0]
103− -- | ```
104− -- |
105− -- | If instead, we had written `main = print []`, the type of the argument
106− -- | `[]` would have been ambiguous, resulting in a compile-time error.
10758 asTypeOf :: forall a. a -> a -> a
10859 asTypeOf x _ = x
10960
110− -- | An alias for `true`, which can be useful in guard clauses:
111− -- |
112− -- | ```purescript
113− -- | max x y | x >= y = x
114− -- | | otherwise = y
115− -- | ```
11661 otherwise :: Boolean
11762 otherwise = true
11863
119− -- | Attaches an element to the front of an array, creating a new array.
120− -- |
121− -- | ```purescript
122− -- | cons 1 [2, 3, 4] = [1, 2, 3, 4]
123− -- | ```
124− -- |
125− -- | Note, the running time of this function is `O(n)`.
12664 foreign import cons
12765 """
12866 function cons(e) {
@@ -134,42 +72,21 @@ module Prelude
13472
13573 infixr 6 :
13674
137− -- | An infix alias for `cons`.
138− -- |
139− -- | Note, the running time of this function is `O(n)`.
14075 (:) :: forall a. a -> [a] -> [a]
14176 (:) = cons
14277
14378 infixr 9 >>>
14479 infixr 9 <<<
14580
146− -- | A `Semigroupoid` is similar to a [`Category`](#category) but does not
147− -- | require an identity element `id`, just composable morphisms.
148− -- |
149− -- | `Semigroupoid`s must satisfy the following law:
150− -- |
151− -- | - Associativity: `p <<< (q <<< r) = (p <<< q) <<< r`
152− -- |
153− -- | One example of a `Semigroupoid` is the function type constructor `(->)`,
154− -- | with `(<<<)` defined as function composition.
15581 class Semigroupoid a where
15682 (<<<) :: forall b c d. a c d -> a b c -> a b d
15783
15884 instance semigroupoidArr :: Semigroupoid (->) where
15985 (<<<) f g x = f (g x)
16086
161− -- | Forwards composition, or `(<<<)` with its arguments reversed.
16287 (>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d
16388 (>>>) f g = g <<< f
16489
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.
168− -- |
169− -- | Instances must satisfy the following law in addition to the
170− -- | `Semigroupoid` law:
171− -- |
172− -- | - Identity: `id <<< p = p <<< id = p`
17390 class (Semigroupoid a) <= Category a where
17491 id :: forall t. a t t
17592
@@ -179,194 +96,55 @@ module Prelude
17996 infixl 4 <$>
18097 infixl 1 <#>
18198
182− -- | A `Functor` is a type constructor which supports a mapping operation
183− -- | `(<$>)`.
184− -- |
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.
188− -- |
189− -- | Instances must satisfy the following laws:
190− -- |
191− -- | - Identity: `(<$>) id = id`
192− -- | - Composition: `(<$>) (f <<< g) = (f <$>) <<< (g <$>)`
19399 class Functor f where
194100 (<$>) :: forall a b. (a -> b) -> f a -> f b
195101
196102 instance functorArr :: Functor ((->) r) where
197103 (<$>) = (<<<)
198104
199− -- | `(<#>)` is `(<$>)` with its arguments reversed. For example:
200− -- |
201− -- | ```purescript
202− -- | [1, 2, 3] <#> \n -> n * n
203− -- | ```
204105 (<#>) :: forall f a b. (Functor f) => f a -> (a -> b) -> f b
205106 (<#>) fa f = f <$> fa
206107
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.
210− -- |
211− -- | `void` is often useful when using `do` notation to change the return type
212− -- | of a monadic computation:
213− -- |
214− -- | ```purescript
215− -- | main = forE 1 10 \n -> void do
216− -- | print n
217− -- | print (n * n)
218− -- | ```
219108 void :: forall f a. (Functor f) => f a -> f Unit
220109 void fa = const unit <$> fa
221110
222111 infixl 4 <*>
223112
224− -- | The `Apply` class provides the `(<*>)` which is used to apply a function
225− -- | to an argument under a type constructor.
226− -- |
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:
230− -- |
231− -- | ```purescript
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
234− -- | ```
235− -- |
236− -- | `(<*>)` is recovered from `lift2` as `lift2 ($)`. That is, `(<*>)` lifts
237− -- | the function application operator `($)` to arguments wrapped with the
238− -- | type constructor `f`.
239− -- |
240− -- | Instances must satisfy the following law in addition to the `Functor`
241− -- | laws:
242− -- |
243− -- | - Associative composition: `(<<<) <$> f <*> g <*> h = f <*> (g <*> h)`
244− -- |
245− -- | Formally, `Apply` represents a strong lax semi-monoidal endofunctor.
246113 class (Functor f) <= Apply f where
247114 (<*>) :: forall a b. f (a -> b) -> f a -> f b
248115
249116 instance applyArr :: Apply ((->) r) where
250117 (<*>) f g x = f x (g x)
251118
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`.
255− -- |
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.
262− -- |
263− -- | Instances must satisfy the following laws in addition to the `Apply`
264− -- | laws:
265− -- |
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`
270119 class (Apply f) <= Applicative f where
271120 pure :: forall a. a -> f a
272121
273122 instance applicativeArr :: Applicative ((->) r) where
274123 pure = const
275124
276− -- | `return` is an alias for `pure`.
277125 return :: forall m a. (Applicative m) => a -> m a
278126 return = pure
279127
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
283− -- | relationship.
284− -- |
285− -- | `liftA1` can therefore be used to write [`Functor`](#functor) instances
286− -- | as follows:
287− -- |
288− -- | ```purescript
289− -- | instance functorF :: Functor F where
290− -- | (<$>) = liftA1
291− -- | ```
292128 liftA1 :: forall f a b. (Applicative f) => (a -> b) -> f a -> f b
293129 liftA1 f a = pure f <*> a
294130
295131 infixl 1 >>=
296132
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.
300− -- |
301− -- | The `>>=` operator can also be expressed using `do` notation, as follows:
302− -- |
303− -- | ```purescript
304− -- | x >>= f = do y <- x
305− -- | f y
306− -- | ```
307− -- |
308− -- | where the function argument of `f` is given the name `y`.
309− -- |
310− -- | Instances must satisfy the following law in addition to the `Apply`
311− -- | laws:
312− -- |
313− -- | - Associativity: `(x >>= f) >>= g = x >>= (\k => f k >>= g)`
314− -- |
315− -- | Associativity tells us that we can regroup operations which use `do`
316− -- | notation so that we can unambiguously write, for example:
317− -- |
318− -- | ```purescript
319− -- | do x <- m1
320− -- | y <- m2 x
321− -- | m3 x y
322− -- | ```
323133 class (Apply m) <= Bind m where
324134 (>>=) :: forall a b. m a -> (a -> m b) -> m b
325135
326136 instance bindArr :: Bind ((->) r) where
327137 (>>=) m f x = f (m x) x
328138
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.
333− -- |
334− -- | Instances must satisfy the following laws in addition to the
335− -- | `Applicative` and `Bind` laws:
336− -- |
337− -- | - Left Identity: `pure x >>= f = f x`
338− -- | - Right Identity: `x >>= pure = x`
339139 class (Applicative m, Bind m) <= Monad m
340140
341141 instance monadArr :: Monad ((->) r)
342142
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.
346− -- |
347− -- | `liftM1` can therefore be used to write [`Functor`](#functor) instances
348− -- | as follows:
349− -- |
350− -- | ```purescript
351− -- | instance functorF :: Functor F where
352− -- | (<$>) = liftM1
353− -- | ```
354143 liftM1 :: forall m a b. (Monad m) => (a -> b) -> m a -> m b
355144 liftM1 f a = do
356145 a' <- a
357146 return (f a')
358147
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.
362− -- |
363− -- | `ap` can therefore be used to write [`Apply`](#apply) instances as
364− -- | follows:
365− -- |
366− -- | ```purescript
367− -- | instance applyF :: Apply F where
368− -- | (<*>) = ap
369− -- | ```
370148 ap :: forall m a b. (Monad m) => m (a -> b) -> m a -> m b
371149 ap f a = do
372150 f' <- f
@@ -376,18 +154,9 @@ module Prelude
376154 infixr 5 <>
377155 infixr 5 ++
378156
379− -- | The `Semigroup` type class identifies an associative operation on a type.
380− -- |
381− -- | Instances are required to satisfy the following law:
382− -- |
383− -- | - Associativity: `(x <> y) <> z = x <> (y <> z)`
384− -- |
385− -- | One example of a `Semigroup` is `String`, with `(<>)` defined as string
386− -- | concatenation.
387157 class Semigroup a where
388158 (<>) :: a -> a -> a
389159
390− -- | `(++)` is an alias for `(<>)`.
391160 (++) :: forall s. (Semigroup s) => s -> s -> s
392161 (++) = (<>)
393162
@@ -417,22 +186,6 @@ module Prelude
417186 infixl 6 +
418187 infixl 7 *
419188
420− -- | The `Semiring` class is for types that support an addition and
421− -- | multiplication operation.
422− -- |
423− -- | Instances must satisfy the following laws:
424− -- |
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`
436189 class Semiring a where
437190 (+) :: a -> a -> a
438191 zero :: a
@@ -453,13 +206,6 @@ module Prelude
453206
454207 infixl 6 -
455208
456− -- | The `Ring` class is for types that support addition, multiplication,
457− -- | and subtraction operations.
458− -- |
459− -- | Instances must satisfy the following law in addition to the `Semiring`
460− -- | laws:
461− -- |
462− -- | - Additive inverse: `a + (-a) = (-a) + a = zero`
463209 class (Semiring a) <= Ring a where
464210 (-) :: a -> a -> a
465211
@@ -474,13 +220,6 @@ module Prelude
474220
475221 infixl 7 /
476222
477− -- | The `ModuloSemiring` class is for types that support addition,
478− -- | multiplication, division, and modulo (division remainder) operations.
479− -- |
480− -- | Instances must satisfy the following law in addition to the `Semiring`
481− -- | laws:
482− -- |
483− -- | - Remainder: `a / b * b + (a `mod` b) = a`
484223 class (Semiring a) <= ModuloSemiring a where
485224 (/) :: a -> a -> a
486225 mod :: a -> a -> a
@@ -493,27 +232,12 @@ module Prelude
493232 (/) _ _ = unit
494233 mod _ _ = unit
495234
496− -- | A `Ring` where every nonzero element has a multiplicative inverse.
497− -- |
498− -- | Instances must satisfy the following law in addition to the `Ring` and
499− -- | `ModuloSemiring` laws:
500− -- |
501− -- | - Multiplicative inverse: `(one / x) * x = one`
502− -- |
503− -- | As a consequence of this ```a `mod` b = zero``` as no divide operation
504− -- | will have a remainder.
505235 class (Ring a, ModuloSemiring a) <= DivisionRing a
506236
507237 instance divisionRingNumber :: DivisionRing Number
508238
509239 instance divisionRingUnit :: DivisionRing Unit
510240
511− -- | The `Num` class is for types that are commutative fields.
512− -- |
513− -- | Instances must satisfy the following law in addition to the
514− -- | `DivisionRing` laws:
515− -- |
516− -- | - Commutative multiplication: `a * b = b * a`
517241 class (DivisionRing a) <= Num a
518242
519243 instance numNumber :: Num Number
@@ -559,16 +283,6 @@ module Prelude
559283 infix 4 ==
560284 infix 4 /=
561285
562− -- | The `Eq` type class represents types which support decidable equality.
563− -- |
564− -- | `Eq` instances should satisfy the following laws:
565− -- |
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)`
570− -- |
571− -- | `(/=)` may be implemented in terms of `(==)`, but it might give a performance improvement to implement it separately.
572286 class Eq a where
573287 (==) :: a -> a -> Boolean
574288 (/=) :: a -> a -> Boolean
@@ -633,21 +347,8 @@ module Prelude
633347 }
634348 """ :: forall a. (a -> a -> Boolean) -> [a] -> [a] -> Boolean
635349
636− -- | The `Ordering` data type represents the three possible outcomes of
637− -- | comparing two values:
638− -- |
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.
642350 data Ordering = LT | GT | EQ
643351
644− -- | The `Ord` type class represents types which support comparisons.
645− -- |
646− -- | `Ord` instances should satisfy the laws of _partially orderings_:
647− -- |
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`
651352 class (Eq a) <= Ord a where
652353 compare :: a -> a -> Ordering
653354
@@ -688,25 +389,21 @@ module Prelude
688389 infixl 4 <=
689390 infixl 4 >=
690391
691− -- | Test whether one value is _strictly less than_ another.
692392 (<) :: forall a. (Ord a) => a -> a -> Boolean
693393 (<) a1 a2 = case a1 `compare` a2 of
694394 LT -> true
695395 _ -> false
696396
697− -- | Test whether one value is _strictly greater than_ another.
698397 (>) :: forall a. (Ord a) => a -> a -> Boolean
699398 (>) a1 a2 = case a1 `compare` a2 of
700399 GT -> true
701400 _ -> false
702401
703− -- | Test whether one value is _non-strictly less than_ another.
704402 (<=) :: forall a. (Ord a) => a -> a -> Boolean
705403 (<=) a1 a2 = case a1 `compare` a2 of
706404 GT -> false
707405 _ -> true
708406
709− -- | Test whether one value is _non-strictly greater than_ another.
710407 (>=) :: forall a. (Ord a) => a -> a -> Boolean
711408 (>=) a1 a2 = case a1 `compare` a2 of
712409 LT -> false
@@ -730,12 +427,6 @@ module Prelude
730427 }
731428 """ :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
732429
733− -- | The `Bounded` type class represents types that are finite partially
734− -- | ordered sets.
735− -- |
736− -- | Instances should satisfy the following law in addition to the `Ord` laws:
737− -- |
738− -- | - Ordering: `bottom <= a <= top`
739430 class (Ord a) <= Bounded a where
740431 top :: a
741432 bottom :: a
@@ -752,24 +443,6 @@ module Prelude
752443 top = GT
753444 bottom = LT
754445
755− -- | The `Lattice` type class represents types that are partially ordered
756− -- | sets with a supremum (`sup` or `||`) and infimum (`inf` or `&&`).
757− -- |
758− -- | Instances should satisfy the following laws in addition to the `Ord`
759− -- | laws:
760− -- |
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`
767− -- | - Absorption:
768− -- | - `a || (a && b) = a`
769− -- | - `a && (a || b) = a`
770− -- | - Idempotent:
771− -- | - `a || a = a`
772− -- | - `a && a = a`
773446 class (Ord a) <= Lattice a where
774447 sup :: a -> a -> a
775448 inf :: a -> a -> a
@@ -785,43 +458,18 @@ module Prelude
785458 infixr 2 ||
786459 infixr 3 &&
787460
788− -- | The `sup` operator.
789461 (||) :: forall a. (Lattice a) => a -> a -> a
790462 (||) = sup
791463
792− -- | The `inf` operator.
793464 (&&) :: forall a. (Lattice a) => a -> a -> a
794465 (&&) = inf
795466
796− -- | The `BoundedLattice` type class represents types that are finite
797− -- | lattices.
798− -- |
799− -- | Instances should satisfy the following law in addition to the `Lattice`
800− -- | and `Bounded` laws:
801− -- |
802− -- | - Identity:
803− -- | - `a || bottom = a`
804− -- | - `a && top = a`
805− -- | - Annihiliation:
806− -- | - `a || top = top`
807− -- | - `a && bottom = bottom`
808467 class (Bounded a, Lattice a) <= BoundedLattice a
809468
810469 instance boundedLatticeBoolean :: BoundedLattice Boolean
811470
812471 instance boundedLatticeUnit :: BoundedLattice Unit
813472
814− -- | The `ComplementedLattice` type class represents types that are lattices
815− -- | where every member is also uniquely complemented.
816− -- |
817− -- | Instances should satisfy the following law in addition to the
818− -- | `BoundedLattice` laws:
819− -- |
820− -- | - Complemented:
821− -- | - `not a || a == top`
822− -- | - `not a && a == bottom`
823− -- | - Double negation:
824− -- | - `not <<< not == id`
825473 class (BoundedLattice a) <= ComplementedLattice a where
826474 not :: a -> a
827475
@@ -831,24 +479,12 @@ module Prelude
831479 instance complementedLatticeUnit :: ComplementedLattice Unit where
832480 not _ = unit
833481
834− -- | The `DistributiveLattice` type class represents types that are lattices
835− -- | where the `&&` and `||` distribute over each other.
836− -- |
837− -- | Instances should satisfy the following law in addition to the `Lattice`
838− -- | laws:
839− -- |
840− -- | - Distributivity: `x && (y || z) = (x && y) || (x && z)`
841482 class (Lattice a) <= DistributiveLattice a
842483
843484 instance distributiveLatticeBoolean :: DistributiveLattice Boolean
844485
845486 instance distributiveLatticeUnit :: DistributiveLattice Unit
846487
847− -- | The `BooleanAlgebra` type class represents types that are Boolean
848− -- | algebras, also known as Boolean lattices.
849− -- |
850− -- | Instances should satisfy the `ComplementedLattice` and
851− -- | `DistributiveLattice` laws.
852488 class (ComplementedLattice a, DistributiveLattice a) <= BooleanAlgebra a
853489
854490 instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
@@ -880,12 +516,6 @@ module Prelude
880516 }
881517 """ :: Boolean -> Boolean
882518
883− -- | The `Show` type class represents those types which can be converted into
884− -- | a human-readable `String` representation.
885− -- |
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`.
889519 class Show a where
890520 show :: a -> String
891521
@@ -939,51 +569,31 @@ module Prelude
939569
940570module Data.Function where
941571
942− -- | The `on` function is used to change the domain of a binary operator.
943− -- |
944− -- | For example, we can create a function which compares two records based on the values of their `x` properties:
945− -- |
946− -- | ```purescript
947− -- | compareX :: forall r. { x :: Number | r } -> { x :: Number | r } -> Ordering
948− -- | compareX = compare `on` _.x
949− -- | ```
950572 on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
951573 on f g x y = g x `f` g y
952574
953− -- | A function of zero arguments
954575 foreign import data Fn0 :: * -> *
955576
956− -- | A function of one argument
957577 foreign import data Fn1 :: * -> * -> *
958578
959− -- | A function of two arguments
960579 foreign import data Fn2 :: * -> * -> * -> *
961580
962− -- | A function of three arguments
963581 foreign import data Fn3 :: * -> * -> * -> * -> *
964582
965− -- | A function of four arguments
966583 foreign import data Fn4 :: * -> * -> * -> * -> * -> *
967584
968− -- | A function of five arguments
969585 foreign import data Fn5 :: * -> * -> * -> * -> * -> * -> *
970586
971− -- | A function of six arguments
972587 foreign import data Fn6 :: * -> * -> * -> * -> * -> * -> * -> *
973588
974− -- | A function of seven arguments
975589 foreign import data Fn7 :: * -> * -> * -> * -> * -> * -> * -> * -> *
976590
977− -- | A function of eight arguments
978591 foreign import data Fn8 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> *
979592
980− -- | A function of nine arguments
981593 foreign import data Fn9 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
982594
983− -- | A function of ten arguments
984595 foreign import data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
985596
986− -- | Create a function of no arguments
987597 foreign import mkFn0
988598 """
989599 function mkFn0(fn) {
@@ -993,7 +603,6 @@ module Data.Function where
993603 }
994604 """ :: forall a. (Unit -> a) -> Fn0 a
995605
996− -- | Create a function of one argument
997606 foreign import mkFn1
998607 """
999608 function mkFn1(fn) {
@@ -1003,7 +612,6 @@ module Data.Function where
1003612 }
1004613 """ :: forall a b. (a -> b) -> Fn1 a b
1005614
1006− -- | Create a function of two arguments from a curried function
1007615 foreign import mkFn2
1008616 """
1009617 function mkFn2(fn) {
@@ -1013,7 +621,6 @@ module Data.Function where
1013621 }
1014622 """ :: forall a b c. (a -> b -> c) -> Fn2 a b c
1015623
1016− -- | Create a function of three arguments from a curried function
1017624 foreign import mkFn3
1018625 """
1019626 function mkFn3(fn) {
@@ -1023,7 +630,6 @@ module Data.Function where
1023630 }
1024631 """ :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d
1025632
1026− -- | Create a function of four arguments from a curried function
1027633 foreign import mkFn4
1028634 """
1029635 function mkFn4(fn) {
@@ -1033,7 +639,6 @@ module Data.Function where
1033639 }
1034640 """ :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e
1035641
1036− -- | Create a function of five arguments from a curried function
1037642 foreign import mkFn5
1038643 """
1039644 function mkFn5(fn) {
@@ -1043,7 +648,6 @@ module Data.Function where
1043648 }
1044649 """ :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f
1045650
1046− -- | Create a function of six arguments from a curried function
1047651 foreign import mkFn6
1048652 """
1049653 function mkFn6(fn) {
@@ -1053,7 +657,6 @@ module Data.Function where
1053657 }
1054658 """ :: forall a b c d e f g. (a -> b -> c -> d -> e -> f -> g) -> Fn6 a b c d e f g
1055659
1056− -- | Create a function of seven arguments from a curried function
1057660 foreign import mkFn7
1058661 """
1059662 function mkFn7(fn) {
@@ -1063,7 +666,6 @@ module Data.Function where
1063666 }
1064667 """ :: 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
1065668
1066− -- | Create a function of eight arguments from a curried function
1067669 foreign import mkFn8
1068670 """
1069671 function mkFn8(fn) {
@@ -1073,7 +675,6 @@ module Data.Function where
1073675 }
1074676 """ :: 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
1075677
1076− -- | Create a function of nine arguments from a curried function
1077678 foreign import mkFn9
1078679 """
1079680 function mkFn9(fn) {
@@ -1083,7 +684,6 @@ module Data.Function where
1083684 }
1084685 """ :: 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
1085686
1086− -- | Create a function of ten arguments from a curried function
1087687 foreign import mkFn10
1088688 """
1089689 function mkFn10(fn) {
@@ -1093,7 +693,6 @@ module Data.Function where
1093693 }
1094694 """ :: 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
1095695
1096− -- | Apply a function of no arguments
1097696 foreign import runFn0
1098697 """
1099698 function runFn0(fn) {
@@ -1101,7 +700,6 @@ module Data.Function where
1101700 }
1102701 """ :: forall a. Fn0 a -> a
1103702
1104− -- | Apply a function of one argument
1105703 foreign import runFn1
1106704 """
1107705 function runFn1(fn) {
@@ -1111,7 +709,6 @@ module Data.Function where
1111709 }
1112710 """ :: forall a b. Fn1 a b -> a -> b
1113711
1114− -- | Apply a function of two arguments
1115712 foreign import runFn2
1116713 """
1117714 function runFn2(fn) {
@@ -1123,7 +720,6 @@ module Data.Function where
1123720 }
1124721 """ :: forall a b c. Fn2 a b c -> a -> b -> c
1125722
1126− -- | Apply a function of three arguments
1127723 foreign import runFn3
1128724 """
1129725 function runFn3(fn) {
@@ -1137,7 +733,6 @@ module Data.Function where
1137733 }
1138734 """ :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d
1139735
1140− -- | Apply a function of four arguments
1141736 foreign import runFn4
1142737 """
1143738 function runFn4(fn) {
@@ -1153,7 +748,6 @@ module Data.Function where
1153748 }
1154749 """ :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e
1155750
1156− -- | Apply a function of five arguments
1157751 foreign import runFn5
1158752 """
1159753 function runFn5(fn) {
@@ -1171,7 +765,6 @@ module Data.Function where
1171765 }
1172766 """ :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f
1173767
1174− -- | Apply a function of six arguments
1175768 foreign import runFn6
1176769 """
1177770 function runFn6(fn) {
@@ -1191,7 +784,6 @@ module Data.Function where
1191784 }
1192785 """ :: forall a b c d e f g. Fn6 a b c d e f g -> a -> b -> c -> d -> e -> f -> g
1193786
1194− -- | Apply a function of seven arguments
1195787 foreign import runFn7
1196788 """
1197789 function runFn7(fn) {
@@ -1213,7 +805,6 @@ module Data.Function where
1213805 }
1214806 """ :: 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
1215807
1216− -- | Apply a function of eight arguments
1217808 foreign import runFn8
1218809 """
1219810 function runFn8(fn) {
@@ -1237,7 +828,6 @@ module Data.Function where
1237828 }
1238829 """ :: 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
1239830
1240− -- | Apply a function of nine arguments
1241831 foreign import runFn9
1242832 """
1243833 function runFn9(fn) {
@@ -1263,7 +853,6 @@ module Data.Function where
1263853 }
1264854 """ :: 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
1265855
1266− -- | Apply a function of ten arguments
1267856 foreign import runFn10
1268857 """
1269858 function runFn10(fn) {
@@ -1293,9 +882,6 @@ module Data.Function where
1293882
1294883module Prelude.Unsafe where
1295884
1296− -- | Find the element of an array at the specified index.
1297− -- |
1298− -- | Note: this function can cause unpredictable failure at runtime if the index is out-of-bounds.
1299885 foreign import unsafeIndex
1300886 """
1301887 function unsafeIndex(xs) {
@@ -1309,14 +895,9 @@ module Control.Monad.Eff
1309895 ( Eff()
1310896 , Pure()
1311897 , runPure
1312− , untilE, whileE, forE, foreachE
898+ , untilE, whileE
1313899 ) where
1314900
1315− -- | The `Eff` type constructor is used to represent _native_ effects.
1316− -- |
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.
1318− -- |
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.
1320901 foreign import data Eff :: # ! -> * -> *
1321902
1322903 foreign import returnE
@@ -1339,15 +920,8 @@ module Control.Monad.Eff
1339920 }
1340921 """ :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
1341922
1342− -- | The `Pure` type synonym represents _pure_ computations, i.e. ones in which all effects have been handled.
1343− -- |
1344− -- | The `runPure` function can be used to run pure computations and obtain their result.
1345923 type Pure a = forall e. Eff e a
1346924
1347− -- | Run a pure computation and return its result.
1348− -- |
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.
1351925 foreign import runPure
1352926 """
1353927 function runPure(f) {
@@ -1369,10 +943,6 @@ module Control.Monad.Eff
1369943
1370944 instance monadEff :: Monad (Eff e)
1371945
1372− -- | Loop until a condition becomes `true`.
1373− -- |
1374− -- | `untilE b` is an effectful computation which repeatedly runs the effectful computation `b`,
1375− -- | until its return value is `true`.
1376946 foreign import untilE
1377947 """
1378948 function untilE(f) {
@@ -1383,10 +953,6 @@ module Control.Monad.Eff
1383953 }
1384954 """ :: forall e. Eff e Boolean -> Eff e Unit
1385955
1386− -- | Loop while a condition is `true`.
1387− -- |
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.
1390956 foreign import whileE
1391957 """
1392958 function whileE(f) {
@@ -1401,63 +967,12 @@ module Control.Monad.Eff
1401967 }
1402968 """ :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
1403969
1404− -- | Loop over a consecutive collection of numbers.
1405− -- |
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
1409− """
1410− function forE(lo) {
1411− return function(hi) {
1412− return function(f) {
1413− return function() {
1414− for (var i = lo; i < hi; i++) {
1415− f(i)();
1416− }
1417− };
1418− };
1419− };
1420− }
1421− """ :: forall e. Number -> Number -> (Number -> Eff e Unit) -> Eff e Unit
1422−
1423− -- | Loop over an array of values.
1424− -- |
1425− -- | `foreach xs f` runs the computation returned by the function `f` for each of the inputs `xs`.
1426− foreign import foreachE
1427− """
1428− function foreachE(as) {
1429− return function(f) {
1430− return function() {
1431− for (var i = 0; i < as.length; i++) {
1432− f(as[i])();
1433− }
1434− };
1435− };
1436− }
1437− """ :: forall e a. [a] -> (a -> Eff e Unit) -> Eff e Unit
1438−
1439−module Control.Monad.Eff.Unsafe where
1440−
1441− import Control.Monad.Eff
1442−
1443− -- | Change the type of an effectful computation, allowing it to be run in another context.
1444− -- |
1445− -- | Note: use of this function can result in arbitrary side-effects.
1446− foreign import unsafeInterleaveEff
1447− """
1448− function unsafeInterleaveEff(f) {
1449− return f;
1450− }
1451− """ :: forall eff1 eff2 a. Eff eff1 a -> Eff eff2 a
1452−
1453970module Debug.Trace where
1454971
1455972 import Control.Monad.Eff
1456973
1457− -- | The `Trace` effect represents those computations which write to the console.
1458974 foreign import data Trace :: !
1459975
1460− -- | Write a `String` to the console.
1461976 foreign import trace
1462977 """
1463978 function trace(s) {
@@ -1468,7 +983,6 @@ module Debug.Trace where
1468983 }
1469984 """ :: forall r. String -> Eff (trace :: Trace | r) Unit
1470985
1471− -- | Write a value to the console, using its `Show` instance to produce a `String`.
1472986 print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit
1473987 print o = trace (show o)
1474988
@@ -1476,17 +990,10 @@ module Control.Monad.ST where
1476990
1477991 import Control.Monad.Eff
1478992
1479− -- | The `ST` effect represents _local mutation_, i.e. mutation which does not "escape" into the surrounding computation.
1480− -- |
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.
1482− -- |
1483− -- | The `runST` function can be used to handle the `ST` effect.
1484993 foreign import data ST :: * -> !
1485994
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.
1487995 foreign import data STRef :: * -> * -> *
1488996
1489− -- | Create a new mutable reference.
1490997 foreign import newSTRef
1491998 """
1492999 function newSTRef(val) {
@@ -1496,7 +1003,6 @@ module Control.Monad.ST where
14961003 }
14971004 """ :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
14981005
1499− -- | Read the current value of a mutable reference.
15001006 foreign import readSTRef
15011007 """
15021008 function readSTRef(ref) {
@@ -1506,7 +1012,6 @@ module Control.Monad.ST where
15061012 }
15071013 """ :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
15081014
1509− -- | Modify the value of a mutable reference by applying a function to the current value.
15101015 foreign import modifySTRef
15111016 """
15121017 function modifySTRef(ref) {
@@ -1518,7 +1023,6 @@ module Control.Monad.ST where
15181023 }
15191024 """ :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
15201025
1521− -- | Set the value of a mutable reference.
15221026 foreign import writeSTRef
15231027 """
15241028 function writeSTRef(ref) {
@@ -1530,12 +1034,6 @@ module Control.Monad.ST where
15301034 }
15311035 """ :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
15321036
1533− -- | Run an `ST` computation.
1534− -- |
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.
1537− -- |
1538− -- | It may cause problems to apply this function using the `$` operator. The recommended approach is to use parentheses instead.
15391037 foreign import runST
15401038 """
15411039 function runST(f) {
@@ -1543,9 +1041,5 @@ module Control.Monad.ST where
15431041 }
15441042 """ :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
15451043
1546− -- | A convenience function which combines `runST` with `runPure`, which can be used when the only required effect is `ST`.
1547− -- |
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.
15501044 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)