@@ -1,1068 +0,0 @@
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−
6−module Prelude
7− ( Unit(..), unit
8− , ($), (#)
9− , flip
10− , const
11− , asTypeOf
12− , otherwise
13− , (:), cons
14− , Semigroupoid, (<<<), (>>>)
15− , Category, id
16− , Functor, (<$>), (<#>), void
17− , Apply, (<*>)
18− , Applicative, pure, liftA1
19− , Bind, (>>=)
20− , Monad, return, liftM1, ap
21− , Semigroup, (<>), (++)
22− , Semiring, (+), zero, (*), one
23− , ModuloSemiring, (/), mod
24− , Ring, (-), negate
25− , Num
26− , DivisionRing
27− , Eq, (==), (/=)
28− , Ordering(..), Ord, compare, (<), (>), (<=), (>=)
29− , Bounded, top, bottom
30− , Lattice, sup, inf, (||), (&&)
31− , BoundedLattice
32− , ComplementedLattice, not
33− , DistributiveLattice
34− , BooleanAlgebra
35− , Show, show
36− ) where
37−
38− newtype Unit = Unit {}
39−
40− unit :: Unit
41− unit = Unit {}
42−
43− infixr 0 $
44− infixl 0 #
45−
46− ($) :: forall a b. (a -> b) -> a -> b
47− ($) f x = f x
48−
49− (#) :: forall a b. a -> (a -> b) -> b
50− (#) x f = f x
51−
52− flip :: forall a b c. (a -> b -> c) -> b -> a -> c
53− flip f b a = f a b
54−
55− const :: forall a b. a -> b -> a
56− const a _ = a
57−
58− asTypeOf :: forall a. a -> a -> a
59− asTypeOf x _ = x
60−
61− otherwise :: Boolean
62− otherwise = true
63−
64− foreign import cons
65− """
66− function cons(e) {
67− return function(l) {
68− return [e].concat(l);
69− };
70− }
71− """ :: forall a. a -> Array a -> Array a
72−
73− infixr 6 :
74−
75− (:) :: forall a. a -> Array a -> Array a
76− (:) = cons
77−
78− infixr 9 >>>
79− infixr 9 <<<
80−
81− class Semigroupoid a where
82− (<<<) :: forall b c d. a c d -> a b c -> a b d
83−
84− instance semigroupoidArr :: Semigroupoid (->) where
85− (<<<) f g x = f (g x)
86−
87− (>>>) :: forall a b c d. (Semigroupoid a) => a b c -> a c d -> a b d
88− (>>>) f g = g <<< f
89−
90− class (Semigroupoid a) <= Category a where
91− id :: forall t. a t t
92−
93− instance categoryArr :: Category (->) where
94− id x = x
95−
96− infixl 4 <$>
97− infixl 1 <#>
98−
99− class Functor f where
100− (<$>) :: forall a b. (a -> b) -> f a -> f b
101−
102− instance functorArr :: Functor ((->) r) where
103− (<$>) = (<<<)
104−
105− (<#>) :: forall f a b. (Functor f) => f a -> (a -> b) -> f b
106− (<#>) fa f = f <$> fa
107−
108− void :: forall f a. (Functor f) => f a -> f Unit
109− void fa = const unit <$> fa
110−
111− infixl 4 <*>
112−
113− class (Functor f) <= Apply f where
114− (<*>) :: forall a b. f (a -> b) -> f a -> f b
115−
116− instance applyArr :: Apply ((->) r) where
117− (<*>) f g x = f x (g x)
118−
119− class (Apply f) <= Applicative f where
120− pure :: forall a. a -> f a
121−
122− instance applicativeArr :: Applicative ((->) r) where
123− pure = const
124−
125− return :: forall m a. (Applicative m) => a -> m a
126− return = pure
127−
128− liftA1 :: forall f a b. (Applicative f) => (a -> b) -> f a -> f b
129− liftA1 f a = pure f <*> a
130−
131− infixl 1 >>=
132−
133− class (Apply m) <= Bind m where
134− (>>=) :: forall a b. m a -> (a -> m b) -> m b
135−
136− instance bindArr :: Bind ((->) r) where
137− (>>=) m f x = f (m x) x
138−
139− class (Applicative m, Bind m) <= Monad m
140−
141− instance monadArr :: Monad ((->) r)
142−
143− liftM1 :: forall m a b. (Monad m) => (a -> b) -> m a -> m b
144− liftM1 f a = do
145− a' <- a
146− return (f a')
147−
148− ap :: forall m a b. (Monad m) => m (a -> b) -> m a -> m b
149− ap f a = do
150− f' <- f
151− a' <- a
152− return (f' a')
153−
154− infixr 5 <>
155− infixr 5 ++
156−
157− class Semigroup a where
158− (<>) :: a -> a -> a
159−
160− (++) :: forall s. (Semigroup s) => s -> s -> s
161− (++) = (<>)
162−
163− instance semigroupString :: Semigroup String where
164− (<>) = concatString
165−
166− instance semigroupUnit :: Semigroup Unit where
167− (<>) _ _ = unit
168−
169− instance semigroupArr :: (Semigroup s') => Semigroup (s -> s') where
170− (<>) f g = \x -> f x <> g x
171−
172− instance semigroupOrdering :: Semigroup Ordering where
173− (<>) LT _ = LT
174− (<>) GT _ = GT
175− (<>) EQ y = y
176−
177− foreign import concatString
178− """
179− function concatString(s1) {
180− return function(s2) {
181− return s1 + s2;
182− };
183− }
184− """ :: String -> String -> String
185−
186− infixl 6 +
187− infixl 7 *
188−
189− class Semiring a where
190− (+) :: a -> a -> a
191− zero :: a
192− (*) :: a -> a -> a
193− one :: a
194−
195− instance semiringNumber :: Semiring Number where
196− (+) = numAdd
197− zero = 0.0
198− (*) = numMul
199− one = 1.0
200−
201− instance semiringUnit :: Semiring Unit where
202− (+) _ _ = unit
203− zero = unit
204− (*) _ _ = unit
205− one = unit
206−
207− infixl 6 -
208−
209− class (Semiring a) <= Ring a where
210− (-) :: a -> a -> a
211−
212− instance ringNumber :: Ring Number where
213− (-) = numSub
214−
215− instance ringUnit :: Ring Unit where
216− (-) _ _ = unit
217−
218− negate :: forall a. (Ring a) => a -> a
219− negate a = zero - a
220−
221− infixl 7 /
222−
223− class (Semiring a) <= ModuloSemiring a where
224− (/) :: a -> a -> a
225− mod :: a -> a -> a
226−
227− instance moduloSemiringNumber :: ModuloSemiring Number where
228− (/) = numDiv
229− mod _ _ = 0.0
230−
231− instance moduloSemiringUnit :: ModuloSemiring Unit where
232− (/) _ _ = unit
233− mod _ _ = unit
234−
235− class (Ring a, ModuloSemiring a) <= DivisionRing a
236−
237− instance divisionRingNumber :: DivisionRing Number
238−
239− instance divisionRingUnit :: DivisionRing Unit
240−
241− class (DivisionRing a) <= Num a
242−
243− instance numNumber :: Num Number
244−
245− instance numUnit :: Num Unit
246−
247− foreign import numAdd
248− """
249− function numAdd(n1) {
250− return function(n2) {
251− return n1 + n2;
252− };
253− }
254− """ :: Number -> Number -> Number
255−
256− foreign import numMul
257− """
258− function numMul(n1) {
259− return function(n2) {
260− return n1 * n2;
261− };
262− }
263− """ :: Number -> Number -> Number
264−
265− foreign import numDiv
266− """
267− function numDiv(n1) {
268− return function(n2) {
269− return n1 / n2;
270− };
271− }
272− """ :: Number -> Number -> Number
273−
274− foreign import numSub
275− """
276− function numSub(n1) {
277− return function(n2) {
278− return n1 - n2;
279− };
280− }
281− """ :: Number -> Number -> Number
282−
283− infix 4 ==
284− infix 4 /=
285−
286− class Eq a where
287− (==) :: a -> a -> Boolean
288− (/=) :: a -> a -> Boolean
289−
290− instance eqBoolean :: Eq Boolean where
291− (==) = refEq
292− (/=) = refIneq
293−
294− instance eqNumber :: Eq Number where
295− (==) = refEq
296− (/=) = refIneq
297−
298− instance eqString :: Eq String where
299− (==) = refEq
300− (/=) = refIneq
301−
302− instance eqUnit :: Eq Unit where
303− (==) _ _ = true
304− (/=) _ _ = false
305−
306− instance eqArray :: (Eq a) => Eq (Array a) where
307− (==) = eqArrayImpl (==)
308− (/=) xs ys = not (xs == ys)
309−
310− instance eqOrdering :: Eq Ordering where
311− (==) LT LT = true
312− (==) GT GT = true
313− (==) EQ EQ = true
314− (==) _ _ = false
315− (/=) x y = not (x == y)
316−
317− foreign import refEq
318− """
319− function refEq(r1) {
320− return function(r2) {
321− return r1 === r2;
322− };
323− }
324− """ :: forall a. a -> a -> Boolean
325−
326− foreign import refIneq
327− """
328− function refIneq(r1) {
329− return function(r2) {
330− return r1 !== r2;
331− };
332− }
333− """ :: forall a. a -> a -> Boolean
334−
335− foreign import eqArrayImpl
336− """
337− function eqArrayImpl(f) {
338− return function(xs) {
339− return function(ys) {
340− if (xs.length !== ys.length) return false;
341− for (var i = 0; i < xs.length; i++) {
342− if (!f(xs[i])(ys[i])) return false;
343− }
344− return true;
345− };
346− };
347− }
348− """ :: forall a. (a -> a -> Boolean) -> Array a -> Array a -> Boolean
349−
350− data Ordering = LT | GT | EQ
351−
352− class (Eq a) <= Ord a where
353− compare :: a -> a -> Ordering
354−
355− instance ordBoolean :: Ord Boolean where
356− compare false false = EQ
357− compare false true = LT
358− compare true true = EQ
359− compare true false = GT
360−
361− instance ordNumber :: Ord Number where
362− compare = unsafeCompare
363−
364− instance ordString :: Ord String where
365− compare = unsafeCompare
366−
367− instance ordUnit :: Ord Unit where
368− compare _ _ = EQ
369−
370− instance ordArray :: (Ord a) => Ord (Array a) where
371− compare xs ys = compare 0.0 $ ordArrayImpl (\x y -> case compare x y of
372− EQ -> 0.0
373− LT -> -1.0
374− GT -> 1.0) xs ys
375−
376− foreign import ordArrayImpl """
377− function ordArrayImpl(f) {
378− return function (ys) {
379− return function (ys) {
380− var i = 0;
381− while (i < xs.length && i < ys.length) {
382− var x = xs[i];
383− var y = ys[i];
384− var o = f(x)(y);
385− if (o !== 0) {
386− return o;
387− }
388− }
389− if (xs.length == ys.length) {
390− return 0;
391− } else if (xs.length > ys.length) {
392− return 1;
393− } else {
394− return -1;
395− }
396− };
397− };
398− }
399− """ :: forall a. (a -> a -> Number) -> Array a -> Array a -> Number
400−
401− instance ordOrdering :: Ord Ordering where
402− compare LT LT = EQ
403− compare EQ EQ = EQ
404− compare GT GT = EQ
405− compare LT _ = LT
406− compare EQ LT = GT
407− compare EQ GT = LT
408− compare GT _ = GT
409−
410− infixl 4 <
411− infixl 4 >
412− infixl 4 <=
413− infixl 4 >=
414−
415− (<) :: forall a. (Ord a) => a -> a -> Boolean
416− (<) a1 a2 = case a1 `compare` a2 of
417− LT -> true
418− _ -> false
419−
420− (>) :: forall a. (Ord a) => a -> a -> Boolean
421− (>) a1 a2 = case a1 `compare` a2 of
422− GT -> true
423− _ -> false
424−
425− (<=) :: forall a. (Ord a) => a -> a -> Boolean
426− (<=) a1 a2 = case a1 `compare` a2 of
427− GT -> false
428− _ -> true
429−
430− (>=) :: forall a. (Ord a) => a -> a -> Boolean
431− (>=) a1 a2 = case a1 `compare` a2 of
432− LT -> false
433− _ -> true
434−
435− unsafeCompare :: forall a. a -> a -> Ordering
436− unsafeCompare = unsafeCompareImpl LT EQ GT
437−
438− foreign import unsafeCompareImpl
439− """
440− function unsafeCompareImpl(lt) {
441− return function(eq) {
442− return function(gt) {
443− return function(x) {
444− return function(y) {
445− return x < y ? lt : x > y ? gt : eq;
446− };
447− };
448− };
449− };
450− }
451− """ :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
452−
453− class (Ord a) <= Bounded a where
454− top :: a
455− bottom :: a
456−
457− instance boundedBoolean :: Bounded Boolean where
458− top = true
459− bottom = false
460−
461− instance boundedUnit :: Bounded Unit where
462− top = unit
463− bottom = unit
464−
465− instance boundedOrdering :: Bounded Ordering where
466− top = GT
467− bottom = LT
468−
469− class (Ord a) <= Lattice a where
470− sup :: a -> a -> a
471− inf :: a -> a -> a
472−
473− instance latticeBoolean :: Lattice Boolean where
474− sup = boolOr
475− inf = boolAnd
476−
477− instance latticeUnit :: Lattice Unit where
478− sup _ _ = unit
479− inf _ _ = unit
480−
481− infixr 2 ||
482− infixr 3 &&
483−
484− (||) :: forall a. (Lattice a) => a -> a -> a
485− (||) = sup
486−
487− (&&) :: forall a. (Lattice a) => a -> a -> a
488− (&&) = inf
489−
490− class (Bounded a, Lattice a) <= BoundedLattice a
491−
492− instance boundedLatticeBoolean :: BoundedLattice Boolean
493−
494− instance boundedLatticeUnit :: BoundedLattice Unit
495−
496− class (BoundedLattice a) <= ComplementedLattice a where
497− not :: a -> a
498−
499− instance complementedLatticeBoolean :: ComplementedLattice Boolean where
500− not = boolNot
501−
502− instance complementedLatticeUnit :: ComplementedLattice Unit where
503− not _ = unit
504−
505− class (Lattice a) <= DistributiveLattice a
506−
507− instance distributiveLatticeBoolean :: DistributiveLattice Boolean
508−
509− instance distributiveLatticeUnit :: DistributiveLattice Unit
510−
511− class (ComplementedLattice a, DistributiveLattice a) <= BooleanAlgebra a
512−
513− instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
514−
515− instance booleanAlgebraUnit :: BooleanAlgebra Unit
516−
517− foreign import boolOr
518− """
519− function boolOr(b1) {
520− return function(b2) {
521− return b1 || b2;
522− };
523− }
524− """ :: Boolean -> Boolean -> Boolean
525−
526− foreign import boolAnd
527− """
528− function boolAnd(b1) {
529− return function(b2) {
530− return b1 && b2;
531− };
532− }
533− """ :: Boolean -> Boolean -> Boolean
534−
535− foreign import boolNot
536− """
537− function boolNot(b) {
538− return !b;
539− }
540− """ :: Boolean -> Boolean
541−
542− class Show a where
543− show :: a -> String
544−
545− instance showBoolean :: Show Boolean where
546− show true = "true"
547− show false = "false"
548−
549− instance showNumber :: Show Number where
550− show = showNumberImpl
551−
552− instance showString :: Show String where
553− show = showStringImpl
554−
555− instance showUnit :: Show Unit where
556− show _ = "unit"
557−
558− instance showArray :: (Show a) => Show (Array a) where
559− show = showArrayImpl show
560−
561− instance showOrdering :: Show Ordering where
562− show LT = "LT"
563− show GT = "GT"
564− show EQ = "EQ"
565−
566− foreign import showNumberImpl
567− """
568− function showNumberImpl(n) {
569− return n.toString();
570− }
571− """ :: Number -> String
572−
573− foreign import showStringImpl
574− """
575− function showStringImpl(s) {
576− return JSON.stringify(s);
577− }
578− """ :: String -> String
579−
580− foreign import showArrayImpl
581− """
582− function showArrayImpl(f) {
583− return function(xs) {
584− var ss = [];
585− for (var i = 0, l = xs.length; i < l; i++) {
586− ss[i] = f(xs[i]);
587− }
588− return '[' + ss.join(',') + ']';
589− };
590− }
591− """ :: forall a. (a -> String) -> Array a -> String
592−
593−module Data.Function where
594−
595− on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
596− on f g x y = g x `f` g y
597−
598− foreign import data Fn0 :: * -> *
599−
600− foreign import data Fn1 :: * -> * -> *
601−
602− foreign import data Fn2 :: * -> * -> * -> *
603−
604− foreign import data Fn3 :: * -> * -> * -> * -> *
605−
606− foreign import data Fn4 :: * -> * -> * -> * -> * -> *
607−
608− foreign import data Fn5 :: * -> * -> * -> * -> * -> * -> *
609−
610− foreign import data Fn6 :: * -> * -> * -> * -> * -> * -> * -> *
611−
612− foreign import data Fn7 :: * -> * -> * -> * -> * -> * -> * -> * -> *
613−
614− foreign import data Fn8 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> *
615−
616− foreign import data Fn9 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
617−
618− foreign import data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
619−
620− foreign import mkFn0
621− """
622− function mkFn0(fn) {
623− return function() {
624− return fn({});
625− };
626− }
627− """ :: forall a. (Unit -> a) -> Fn0 a
628−
629− foreign import mkFn1
630− """
631− function mkFn1(fn) {
632− return function(a) {
633− return fn(a);
634− };
635− }
636− """ :: forall a b. (a -> b) -> Fn1 a b
637−
638− foreign import mkFn2
639− """
640− function mkFn2(fn) {
641− return function(a, b) {
642− return fn(a)(b);
643− };
644− }
645− """ :: forall a b c. (a -> b -> c) -> Fn2 a b c
646−
647− foreign import mkFn3
648− """
649− function mkFn3(fn) {
650− return function(a, b, c) {
651− return fn(a)(b)(c);
652− };
653− }
654− """ :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d
655−
656− foreign import mkFn4
657− """
658− function mkFn4(fn) {
659− return function(a, b, c, d) {
660− return fn(a)(b)(c)(d);
661− };
662− }
663− """ :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e
664−
665− foreign import mkFn5
666− """
667− function mkFn5(fn) {
668− return function(a, b, c, d, e) {
669− return fn(a)(b)(c)(d)(e);
670− };
671− }
672− """ :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f
673−
674− foreign import mkFn6
675− """
676− function mkFn6(fn) {
677− return function(a, b, c, d, e, f) {
678− return fn(a)(b)(c)(d)(e)(f);
679− };
680− }
681− """ :: forall a b c d e f g. (a -> b -> c -> d -> e -> f -> g) -> Fn6 a b c d e f g
682−
683− foreign import mkFn7
684− """
685− function mkFn7(fn) {
686− return function(a, b, c, d, e, f, g) {
687− return fn(a)(b)(c)(d)(e)(f)(g);
688− };
689− }
690− """ :: 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
691−
692− foreign import mkFn8
693− """
694− function mkFn8(fn) {
695− return function(a, b, c, d, e, f, g, h) {
696− return fn(a)(b)(c)(d)(e)(f)(g)(h);
697− };
698− }
699− """ :: 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
700−
701− foreign import mkFn9
702− """
703− function mkFn9(fn) {
704− return function(a, b, c, d, e, f, g, h, i) {
705− return fn(a)(b)(c)(d)(e)(f)(g)(h)(i);
706− };
707− }
708− """ :: 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
709−
710− foreign import mkFn10
711− """
712− function mkFn10(fn) {
713− return function(a, b, c, d, e, f, g, h, i, j) {
714− return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(j);
715− };
716− }
717− """ :: 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
718−
719− foreign import runFn0
720− """
721− function runFn0(fn) {
722− return fn();
723− }
724− """ :: forall a. Fn0 a -> a
725−
726− foreign import runFn1
727− """
728− function runFn1(fn) {
729− return function(a) {
730− return fn(a);
731− };
732− }
733− """ :: forall a b. Fn1 a b -> a -> b
734−
735− foreign import runFn2
736− """
737− function runFn2(fn) {
738− return function(a) {
739− return function(b) {
740− return fn(a, b);
741− };
742− };
743− }
744− """ :: forall a b c. Fn2 a b c -> a -> b -> c
745−
746− foreign import runFn3
747− """
748− function runFn3(fn) {
749− return function(a) {
750− return function(b) {
751− return function(c) {
752− return fn(a, b, c);
753− };
754− };
755− };
756− }
757− """ :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d
758−
759− foreign import runFn4
760− """
761− function runFn4(fn) {
762− return function(a) {
763− return function(b) {
764− return function(c) {
765− return function(d) {
766− return fn(a, b, c, d);
767− };
768− };
769− };
770− };
771− }
772− """ :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e
773−
774− foreign import runFn5
775− """
776− function runFn5(fn) {
777− return function(a) {
778− return function(b) {
779− return function(c) {
780− return function(d) {
781− return function(e) {
782− return fn(a, b, c, d, e);
783− };
784− };
785− };
786− };
787− };
788− }
789− """ :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f
790−
791− foreign import runFn6
792− """
793− function runFn6(fn) {
794− return function(a) {
795− return function(b) {
796− return function(c) {
797− return function(d) {
798− return function(e) {
799− return function(f) {
800− return fn(a, b, c, d, e, f);
801− };
802− };
803− };
804− };
805− };
806− };
807− }
808− """ :: forall a b c d e f g. Fn6 a b c d e f g -> a -> b -> c -> d -> e -> f -> g
809−
810− foreign import runFn7
811− """
812− function runFn7(fn) {
813− return function(a) {
814− return function(b) {
815− return function(c) {
816− return function(d) {
817− return function(e) {
818− return function(f) {
819− return function(g) {
820− return fn(a, b, c, d, e, f, g);
821− };
822− };
823− };
824− };
825− };
826− };
827− };
828− }
829− """ :: 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
830−
831− foreign import runFn8
832− """
833− function runFn8(fn) {
834− return function(a) {
835− return function(b) {
836− return function(c) {
837− return function(d) {
838− return function(e) {
839− return function(f) {
840− return function(g) {
841− return function(h) {
842− return fn(a, b, c, d, e, f, g, h);
843− };
844− };
845− };
846− };
847− };
848− };
849− };
850− };
851− }
852− """ :: 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
853−
854− foreign import runFn9
855− """
856− function runFn9(fn) {
857− return function(a) {
858− return function(b) {
859− return function(c) {
860− return function(d) {
861− return function(e) {
862− return function(f) {
863− return function(g) {
864− return function(h) {
865− return function(i) {
866− return fn(a, b, c, d, e, f, g, h, i);
867− };
868− };
869− };
870− };
871− };
872− };
873− };
874− };
875− };
876− }
877− """ :: 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
878−
879− foreign import runFn10
880− """
881− function runFn10(fn) {
882− return function(a) {
883− return function(b) {
884− return function(c) {
885− return function(d) {
886− return function(e) {
887− return function(f) {
888− return function(g) {
889− return function(h) {
890− return function(i) {
891− return function(j) {
892− return fn(a, b, c, d, e, f, g, h, i, j);
893− };
894− };
895− };
896− };
897− };
898− };
899− };
900− };
901− };
902− };
903− }
904− """ :: forall a b c d e f g h i j k. Fn10 a b c d e f g h i j k -> a -> b -> c -> d -> e -> f -> g -> h -> i -> j -> k
905−
906−module Prelude.Unsafe where
907−
908− foreign import unsafeIndex
909− """
910− function unsafeIndex(xs) {
911− return function(n) {
912− return xs[n];
913− };
914− }
915− """ :: forall a. Array a -> Number -> a
916−
917−module Control.Monad.Eff
918− ( Eff()
919− , Pure()
920− , runPure
921− , untilE, whileE
922− ) where
923−
924− foreign import data Eff :: # ! -> * -> *
925−
926− foreign import returnE
927− """
928− function returnE(a) {
929− return function() {
930− return a;
931− };
932− }
933− """ :: forall e a. a -> Eff e a
934−
935− foreign import bindE
936− """
937− function bindE(a) {
938− return function(f) {
939− return function() {
940− return f(a())();
941− };
942− };
943− }
944− """ :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
945−
946− type Pure a = forall e. Eff e a
947−
948− foreign import runPure
949− """
950− function runPure(f) {
951− return f();
952− }
953− """ :: forall a. Pure a -> a
954−
955− instance functorEff :: Functor (Eff e) where
956− (<$>) = liftA1
957−
958− instance applyEff :: Apply (Eff e) where
959− (<*>) = ap
960−
961− instance applicativeEff :: Applicative (Eff e) where
962− pure = returnE
963−
964− instance bindEff :: Bind (Eff e) where
965− (>>=) = bindE
966−
967− instance monadEff :: Monad (Eff e)
968−
969− foreign import untilE
970− """
971− function untilE(f) {
972− return function() {
973− while (!f());
974− return {};
975− };
976− }
977− """ :: forall e. Eff e Boolean -> Eff e Unit
978−
979− foreign import whileE
980− """
981− function whileE(f) {
982− return function(a) {
983− return function() {
984− while (f()) {
985− a();
986− }
987− return {};
988− };
989− };
990− }
991− """ :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
992−
993−module Debug.Trace where
994−
995− import Control.Monad.Eff
996−
997− foreign import data Trace :: !
998−
999− foreign import trace
1000− """
1001− function trace(s) {
1002− return function() {
1003− console.log(s);
1004− return {};
1005− };
1006− }
1007− """ :: forall r. String -> Eff (trace :: Trace | r) Unit
1008−
1009− print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit
1010− print o = trace (show o)
1011−
1012−module Control.Monad.ST where
1013−
1014− import Control.Monad.Eff
1015−
1016− foreign import data ST :: * -> !
1017−
1018− foreign import data STRef :: * -> * -> *
1019−
1020− foreign import newSTRef
1021− """
1022− function newSTRef(val) {
1023− return function() {
1024− return { value: val };
1025− };
1026− }
1027− """ :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
1028−
1029− foreign import readSTRef
1030− """
1031− function readSTRef(ref) {
1032− return function() {
1033− return ref.value;
1034− };
1035− }
1036− """ :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
1037−
1038− foreign import modifySTRef
1039− """
1040− function modifySTRef(ref) {
1041− return function(f) {
1042− return function() {
1043− return ref.value = f(ref.value);
1044− };
1045− };
1046− }
1047− """ :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
1048−
1049− foreign import writeSTRef
1050− """
1051− function writeSTRef(ref) {
1052− return function(a) {
1053− return function() {
1054− return ref.value = a;
1055− };
1056− };
1057− }
1058− """ :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
1059−
1060− foreign import runST
1061− """
1062− function runST(f) {
1063− return f;
1064− }
1065− """ :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
1066−
1067− pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
1068− pureST st = runPure (runST st)