@@ -0,0 +1,1045 @@
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 -> [a] -> [a]
72+
73+ infixr 6 :
74+
75+ (:) :: forall a. a -> [a] -> [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
198+ (*) = numMul
199+ one = 1
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
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 [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) -> [a] -> [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 [a] where
371+ compare [] [] = EQ
372+ compare [] _ = LT
373+ compare _ [] = GT
374+ compare (x:xs) (y:ys) = case compare x y of
375+ EQ -> compare xs ys
376+ other -> other
377+
378+ instance ordOrdering :: Ord Ordering where
379+ compare LT LT = EQ
380+ compare EQ EQ = EQ
381+ compare GT GT = EQ
382+ compare LT _ = LT
383+ compare EQ LT = GT
384+ compare EQ GT = LT
385+ compare GT _ = GT
386+
387+ infixl 4 <
388+ infixl 4 >
389+ infixl 4 <=
390+ infixl 4 >=
391+
392+ (<) :: forall a. (Ord a) => a -> a -> Boolean
393+ (<) a1 a2 = case a1 `compare` a2 of
394+ LT -> true
395+ _ -> false
396+
397+ (>) :: forall a. (Ord a) => a -> a -> Boolean
398+ (>) a1 a2 = case a1 `compare` a2 of
399+ GT -> true
400+ _ -> false
401+
402+ (<=) :: forall a. (Ord a) => a -> a -> Boolean
403+ (<=) a1 a2 = case a1 `compare` a2 of
404+ GT -> false
405+ _ -> true
406+
407+ (>=) :: forall a. (Ord a) => a -> a -> Boolean
408+ (>=) a1 a2 = case a1 `compare` a2 of
409+ LT -> false
410+ _ -> true
411+
412+ unsafeCompare :: forall a. a -> a -> Ordering
413+ unsafeCompare = unsafeCompareImpl LT EQ GT
414+
415+ foreign import unsafeCompareImpl
416+ """
417+ function unsafeCompareImpl(lt) {
418+ return function(eq) {
419+ return function(gt) {
420+ return function(x) {
421+ return function(y) {
422+ return x < y ? lt : x > y ? gt : eq;
423+ };
424+ };
425+ };
426+ };
427+ }
428+ """ :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
429+
430+ class (Ord a) <= Bounded a where
431+ top :: a
432+ bottom :: a
433+
434+ instance boundedBoolean :: Bounded Boolean where
435+ top = true
436+ bottom = false
437+
438+ instance boundedUnit :: Bounded Unit where
439+ top = unit
440+ bottom = unit
441+
442+ instance boundedOrdering :: Bounded Ordering where
443+ top = GT
444+ bottom = LT
445+
446+ class (Ord a) <= Lattice a where
447+ sup :: a -> a -> a
448+ inf :: a -> a -> a
449+
450+ instance latticeBoolean :: Lattice Boolean where
451+ sup = boolOr
452+ inf = boolAnd
453+
454+ instance latticeUnit :: Lattice Unit where
455+ sup _ _ = unit
456+ inf _ _ = unit
457+
458+ infixr 2 ||
459+ infixr 3 &&
460+
461+ (||) :: forall a. (Lattice a) => a -> a -> a
462+ (||) = sup
463+
464+ (&&) :: forall a. (Lattice a) => a -> a -> a
465+ (&&) = inf
466+
467+ class (Bounded a, Lattice a) <= BoundedLattice a
468+
469+ instance boundedLatticeBoolean :: BoundedLattice Boolean
470+
471+ instance boundedLatticeUnit :: BoundedLattice Unit
472+
473+ class (BoundedLattice a) <= ComplementedLattice a where
474+ not :: a -> a
475+
476+ instance complementedLatticeBoolean :: ComplementedLattice Boolean where
477+ not = boolNot
478+
479+ instance complementedLatticeUnit :: ComplementedLattice Unit where
480+ not _ = unit
481+
482+ class (Lattice a) <= DistributiveLattice a
483+
484+ instance distributiveLatticeBoolean :: DistributiveLattice Boolean
485+
486+ instance distributiveLatticeUnit :: DistributiveLattice Unit
487+
488+ class (ComplementedLattice a, DistributiveLattice a) <= BooleanAlgebra a
489+
490+ instance booleanAlgebraBoolean :: BooleanAlgebra Boolean
491+
492+ instance booleanAlgebraUnit :: BooleanAlgebra Unit
493+
494+ foreign import boolOr
495+ """
496+ function boolOr(b1) {
497+ return function(b2) {
498+ return b1 || b2;
499+ };
500+ }
501+ """ :: Boolean -> Boolean -> Boolean
502+
503+ foreign import boolAnd
504+ """
505+ function boolAnd(b1) {
506+ return function(b2) {
507+ return b1 && b2;
508+ };
509+ }
510+ """ :: Boolean -> Boolean -> Boolean
511+
512+ foreign import boolNot
513+ """
514+ function boolNot(b) {
515+ return !b;
516+ }
517+ """ :: Boolean -> Boolean
518+
519+ class Show a where
520+ show :: a -> String
521+
522+ instance showBoolean :: Show Boolean where
523+ show true = "true"
524+ show false = "false"
525+
526+ instance showNumber :: Show Number where
527+ show = showNumberImpl
528+
529+ instance showString :: Show String where
530+ show = showStringImpl
531+
532+ instance showUnit :: Show Unit where
533+ show _ = "unit"
534+
535+ instance showArray :: (Show a) => Show [a] where
536+ show = showArrayImpl show
537+
538+ instance showOrdering :: Show Ordering where
539+ show LT = "LT"
540+ show GT = "GT"
541+ show EQ = "EQ"
542+
543+ foreign import showNumberImpl
544+ """
545+ function showNumberImpl(n) {
546+ return n.toString();
547+ }
548+ """ :: Number -> String
549+
550+ foreign import showStringImpl
551+ """
552+ function showStringImpl(s) {
553+ return JSON.stringify(s);
554+ }
555+ """ :: String -> String
556+
557+ foreign import showArrayImpl
558+ """
559+ function showArrayImpl(f) {
560+ return function(xs) {
561+ var ss = [];
562+ for (var i = 0, l = xs.length; i < l; i++) {
563+ ss[i] = f(xs[i]);
564+ }
565+ return '[' + ss.join(',') + ']';
566+ };
567+ }
568+ """ :: forall a. (a -> String) -> [a] -> String
569+
570+module Data.Function where
571+
572+ on :: forall a b c. (b -> b -> c) -> (a -> b) -> a -> a -> c
573+ on f g x y = g x `f` g y
574+
575+ foreign import data Fn0 :: * -> *
576+
577+ foreign import data Fn1 :: * -> * -> *
578+
579+ foreign import data Fn2 :: * -> * -> * -> *
580+
581+ foreign import data Fn3 :: * -> * -> * -> * -> *
582+
583+ foreign import data Fn4 :: * -> * -> * -> * -> * -> *
584+
585+ foreign import data Fn5 :: * -> * -> * -> * -> * -> * -> *
586+
587+ foreign import data Fn6 :: * -> * -> * -> * -> * -> * -> * -> *
588+
589+ foreign import data Fn7 :: * -> * -> * -> * -> * -> * -> * -> * -> *
590+
591+ foreign import data Fn8 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> *
592+
593+ foreign import data Fn9 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
594+
595+ foreign import data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
596+
597+ foreign import mkFn0
598+ """
599+ function mkFn0(fn) {
600+ return function() {
601+ return fn({});
602+ };
603+ }
604+ """ :: forall a. (Unit -> a) -> Fn0 a
605+
606+ foreign import mkFn1
607+ """
608+ function mkFn1(fn) {
609+ return function(a) {
610+ return fn(a);
611+ };
612+ }
613+ """ :: forall a b. (a -> b) -> Fn1 a b
614+
615+ foreign import mkFn2
616+ """
617+ function mkFn2(fn) {
618+ return function(a, b) {
619+ return fn(a)(b);
620+ };
621+ }
622+ """ :: forall a b c. (a -> b -> c) -> Fn2 a b c
623+
624+ foreign import mkFn3
625+ """
626+ function mkFn3(fn) {
627+ return function(a, b, c) {
628+ return fn(a)(b)(c);
629+ };
630+ }
631+ """ :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d
632+
633+ foreign import mkFn4
634+ """
635+ function mkFn4(fn) {
636+ return function(a, b, c, d) {
637+ return fn(a)(b)(c)(d);
638+ };
639+ }
640+ """ :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e
641+
642+ foreign import mkFn5
643+ """
644+ function mkFn5(fn) {
645+ return function(a, b, c, d, e) {
646+ return fn(a)(b)(c)(d)(e);
647+ };
648+ }
649+ """ :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f
650+
651+ foreign import mkFn6
652+ """
653+ function mkFn6(fn) {
654+ return function(a, b, c, d, e, f) {
655+ return fn(a)(b)(c)(d)(e)(f);
656+ };
657+ }
658+ """ :: forall a b c d e f g. (a -> b -> c -> d -> e -> f -> g) -> Fn6 a b c d e f g
659+
660+ foreign import mkFn7
661+ """
662+ function mkFn7(fn) {
663+ return function(a, b, c, d, e, f, g) {
664+ return fn(a)(b)(c)(d)(e)(f)(g);
665+ };
666+ }
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
668+
669+ foreign import mkFn8
670+ """
671+ function mkFn8(fn) {
672+ return function(a, b, c, d, e, f, g, h) {
673+ return fn(a)(b)(c)(d)(e)(f)(g)(h);
674+ };
675+ }
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
677+
678+ foreign import mkFn9
679+ """
680+ function mkFn9(fn) {
681+ return function(a, b, c, d, e, f, g, h, i) {
682+ return fn(a)(b)(c)(d)(e)(f)(g)(h)(i);
683+ };
684+ }
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
686+
687+ foreign import mkFn10
688+ """
689+ function mkFn10(fn) {
690+ return function(a, b, c, d, e, f, g, h, i, j) {
691+ return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(j);
692+ };
693+ }
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
695+
696+ foreign import runFn0
697+ """
698+ function runFn0(fn) {
699+ return fn();
700+ }
701+ """ :: forall a. Fn0 a -> a
702+
703+ foreign import runFn1
704+ """
705+ function runFn1(fn) {
706+ return function(a) {
707+ return fn(a);
708+ };
709+ }
710+ """ :: forall a b. Fn1 a b -> a -> b
711+
712+ foreign import runFn2
713+ """
714+ function runFn2(fn) {
715+ return function(a) {
716+ return function(b) {
717+ return fn(a, b);
718+ };
719+ };
720+ }
721+ """ :: forall a b c. Fn2 a b c -> a -> b -> c
722+
723+ foreign import runFn3
724+ """
725+ function runFn3(fn) {
726+ return function(a) {
727+ return function(b) {
728+ return function(c) {
729+ return fn(a, b, c);
730+ };
731+ };
732+ };
733+ }
734+ """ :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d
735+
736+ foreign import runFn4
737+ """
738+ function runFn4(fn) {
739+ return function(a) {
740+ return function(b) {
741+ return function(c) {
742+ return function(d) {
743+ return fn(a, b, c, d);
744+ };
745+ };
746+ };
747+ };
748+ }
749+ """ :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e
750+
751+ foreign import runFn5
752+ """
753+ function runFn5(fn) {
754+ return function(a) {
755+ return function(b) {
756+ return function(c) {
757+ return function(d) {
758+ return function(e) {
759+ return fn(a, b, c, d, e);
760+ };
761+ };
762+ };
763+ };
764+ };
765+ }
766+ """ :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f
767+
768+ foreign import runFn6
769+ """
770+ function runFn6(fn) {
771+ return function(a) {
772+ return function(b) {
773+ return function(c) {
774+ return function(d) {
775+ return function(e) {
776+ return function(f) {
777+ return fn(a, b, c, d, e, f);
778+ };
779+ };
780+ };
781+ };
782+ };
783+ };
784+ }
785+ """ :: forall a b c d e f g. Fn6 a b c d e f g -> a -> b -> c -> d -> e -> f -> g
786+
787+ foreign import runFn7
788+ """
789+ function runFn7(fn) {
790+ return function(a) {
791+ return function(b) {
792+ return function(c) {
793+ return function(d) {
794+ return function(e) {
795+ return function(f) {
796+ return function(g) {
797+ return fn(a, b, c, d, e, f, g);
798+ };
799+ };
800+ };
801+ };
802+ };
803+ };
804+ };
805+ }
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
807+
808+ foreign import runFn8
809+ """
810+ function runFn8(fn) {
811+ return function(a) {
812+ return function(b) {
813+ return function(c) {
814+ return function(d) {
815+ return function(e) {
816+ return function(f) {
817+ return function(g) {
818+ return function(h) {
819+ return fn(a, b, c, d, e, f, g, h);
820+ };
821+ };
822+ };
823+ };
824+ };
825+ };
826+ };
827+ };
828+ }
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
830+
831+ foreign import runFn9
832+ """
833+ function runFn9(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 function(i) {
843+ return fn(a, b, c, d, e, f, g, h, i);
844+ };
845+ };
846+ };
847+ };
848+ };
849+ };
850+ };
851+ };
852+ };
853+ }
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
855+
856+ foreign import runFn10
857+ """
858+ function runFn10(fn) {
859+ return function(a) {
860+ return function(b) {
861+ return function(c) {
862+ return function(d) {
863+ return function(e) {
864+ return function(f) {
865+ return function(g) {
866+ return function(h) {
867+ return function(i) {
868+ return function(j) {
869+ return fn(a, b, c, d, e, f, g, h, i, j);
870+ };
871+ };
872+ };
873+ };
874+ };
875+ };
876+ };
877+ };
878+ };
879+ };
880+ }
881+ """ :: 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
882+
883+module Prelude.Unsafe where
884+
885+ foreign import unsafeIndex
886+ """
887+ function unsafeIndex(xs) {
888+ return function(n) {
889+ return xs[n];
890+ };
891+ }
892+ """ :: forall a. [a] -> Number -> a
893+
894+module Control.Monad.Eff
895+ ( Eff()
896+ , Pure()
897+ , runPure
898+ , untilE, whileE
899+ ) where
900+
901+ foreign import data Eff :: # ! -> * -> *
902+
903+ foreign import returnE
904+ """
905+ function returnE(a) {
906+ return function() {
907+ return a;
908+ };
909+ }
910+ """ :: forall e a. a -> Eff e a
911+
912+ foreign import bindE
913+ """
914+ function bindE(a) {
915+ return function(f) {
916+ return function() {
917+ return f(a())();
918+ };
919+ };
920+ }
921+ """ :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
922+
923+ type Pure a = forall e. Eff e a
924+
925+ foreign import runPure
926+ """
927+ function runPure(f) {
928+ return f();
929+ }
930+ """ :: forall a. Pure a -> a
931+
932+ instance functorEff :: Functor (Eff e) where
933+ (<$>) = liftA1
934+
935+ instance applyEff :: Apply (Eff e) where
936+ (<*>) = ap
937+
938+ instance applicativeEff :: Applicative (Eff e) where
939+ pure = returnE
940+
941+ instance bindEff :: Bind (Eff e) where
942+ (>>=) = bindE
943+
944+ instance monadEff :: Monad (Eff e)
945+
946+ foreign import untilE
947+ """
948+ function untilE(f) {
949+ return function() {
950+ while (!f());
951+ return {};
952+ };
953+ }
954+ """ :: forall e. Eff e Boolean -> Eff e Unit
955+
956+ foreign import whileE
957+ """
958+ function whileE(f) {
959+ return function(a) {
960+ return function() {
961+ while (f()) {
962+ a();
963+ }
964+ return {};
965+ };
966+ };
967+ }
968+ """ :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
969+
970+module Debug.Trace where
971+
972+ import Control.Monad.Eff
973+
974+ foreign import data Trace :: !
975+
976+ foreign import trace
977+ """
978+ function trace(s) {
979+ return function() {
980+ console.log(s);
981+ return {};
982+ };
983+ }
984+ """ :: forall r. String -> Eff (trace :: Trace | r) Unit
985+
986+ print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit
987+ print o = trace (show o)
988+
989+module Control.Monad.ST where
990+
991+ import Control.Monad.Eff
992+
993+ foreign import data ST :: * -> !
994+
995+ foreign import data STRef :: * -> * -> *
996+
997+ foreign import newSTRef
998+ """
999+ function newSTRef(val) {
1000+ return function() {
1001+ return { value: val };
1002+ };
1003+ }
1004+ """ :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
1005+
1006+ foreign import readSTRef
1007+ """
1008+ function readSTRef(ref) {
1009+ return function() {
1010+ return ref.value;
1011+ };
1012+ }
1013+ """ :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
1014+
1015+ foreign import modifySTRef
1016+ """
1017+ function modifySTRef(ref) {
1018+ return function(f) {
1019+ return function() {
1020+ return ref.value = f(ref.value);
1021+ };
1022+ };
1023+ }
1024+ """ :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
1025+
1026+ foreign import writeSTRef
1027+ """
1028+ function writeSTRef(ref) {
1029+ return function(a) {
1030+ return function() {
1031+ return ref.value = a;
1032+ };
1033+ };
1034+ }
1035+ """ :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
1036+
1037+ foreign import runST
1038+ """
1039+ function runST(f) {
1040+ return f;
1041+ }
1042+ """ :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
1043+
1044+ pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
1045+ pureST st = runPure (runST st)