@@ -13,8 +13,13 @@ module Prelude
13 , Applicative, pure, liftA1
13 , Applicative, pure, liftA1
14 , Bind, (>>=)
14 , Bind, (>>=)
15 , Monad, return, liftM1, ap
15 , Monad, return, liftM1, ap
16− , Num, (+), (-), (*), (/), (%)
16+ , Semiring, (+), zero, (*), one
17+ , ModuloSemiring, (/), mod
18 , Eq, (==), (/=), refEq, refIneq
23 , Eq, (==), (/=), refEq, refIneq
19 , Ord, Ordering(..), compare, (<), (>), (<=), (>=)
24 , Ord, Ordering(..), compare, (<), (>), (<=), (>=)
20 , Bits, (.&.), (.|.), (.^.), shl, shr, zshr, complement
25 , Bits, (.&.), (.|.), (.^.), shl, shr, zshr, complement
@@ -24,15 +29,32 @@ module Prelude
24 , Unit(..), unit
29 , Unit(..), unit
32+ -- | An alias for `true`, which can be useful in guard clauses:
36+ -- | max x y | x >= y = x
27 otherwise :: Boolean
38 otherwise :: Boolean
28 otherwise = true
39 otherwise = true
41+ -- | Flips the order of the arguments to a function of two arguments.
30 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
42 flip :: forall a b c. (a -> b -> c) -> b -> a -> c
31 flip f b a = f a b
43 flip f b a = f a b
45+ -- | Returns its first argument and ignores its second.
33 const :: forall a b. a -> b -> a
46 const :: forall a b. a -> b -> a
34 const a _ = a
47 const a _ = a
49+ -- | This function returns its first argument, and can be used to assert type equalities.
50+ -- | This can be useful when types are otherwise ambiguous.
54+ -- | main = print $ [] `asTypeOf` [0]
56+ -- | If instead, we had written `main = print []`, the type of the argument `[]` would have
57+ -- | been ambiguous, resulting in a compile-time error.
36 asTypeOf :: forall a. a -> a -> a
58 asTypeOf :: forall a. a -> a -> a
37 asTypeOf x _ = x
59 asTypeOf x _ = x
@@ -69,19 +91,23 @@ module Prelude
69 (:) = cons
91 (:) = cons
71 foreign import cons
93 foreign import cons
72− "function cons(e) {\
95+ function cons(e) {
73− \ return function(l) {\
96+ return function(l) {
74− \ return [e].concat(l);\
97+ return [e].concat(l);
76− \}" :: forall a. a -> [a] -> [a]
100+ """ :: forall a. a -> [a] -> [a]
78 class Show a where
102 class Show a where
79 show :: a -> String
103 show :: a -> String
81 foreign import showStringImpl
105 foreign import showStringImpl
82− "function showStringImpl(s) {\
107+ function showStringImpl(s) {
83− \ return JSON.stringify(s);\
108+ return JSON.stringify(s);
84− \}" :: String -> String
110+ """ :: String -> String
86 instance showUnit :: Show Unit where
112 instance showUnit :: Show Unit where
87 show (Unit {}) = "Unit {}"
113 show (Unit {}) = "Unit {}"
@@ -93,23 +119,28 @@ module Prelude
93 show true = "true"
119 show true = "true"
94 show false = "false"
120 show false = "false"
96− foreign import showNumberImpl "function showNumberImpl(n) {\
122+ foreign import showNumberImpl
124+ function showNumberImpl(n) {
97− \ return n.toString();\
125+ return n.toString();
98− \}" :: Number -> String
127+ """ :: Number -> String
100 instance showNumber :: Show Number where
129 instance showNumber :: Show Number where
101 show = showNumberImpl
130 show = showNumberImpl
103 foreign import showArrayImpl
132 foreign import showArrayImpl
104− "function showArrayImpl(f) {\
134+ function showArrayImpl(f) {
105− \ return function(xs) {\
135+ return function(xs) {
106− \ var ss = [];\
136+ var ss = [];
107− \ for (var i = 0, l = xs.length; i < l; i++) {\
137+ for (var i = 0, l = xs.length; i < l; i++) {
108− \ ss[i] = f(xs[i]);\
138+ ss[i] = f(xs[i]);
110− \ return '[' + ss.join(',') + ']';\
140+ return '[' + ss.join(',') + ']';
112− \}" :: forall a. (a -> String) -> [a] -> String
143+ """ :: forall a. (a -> String) -> [a] -> String
114 instance showArray :: (Show a) => Show [a] where
145 instance showArray :: (Show a) => Show [a] where
115 show = showArrayImpl show
146 show = showArrayImpl show
@@ -179,55 +210,96 @@ module Prelude
179 infixl 6 -
210 infixl 6 -
180 infixl 6 +
211 infixl 6 +
213+ -- | Addition and multiplication
182− class Num a where
214+ class Semiring a where
183− (+) :: a -> a -> a
215+ (+) :: a -> a -> a
184− (-) :: a -> a -> a
217+ (*) :: a -> a -> a
185− (*) :: a -> a -> a
218+ one :: a
220+ -- | Semiring with modulo operation and division where
221+ -- | ```a / b * b + (a `mod` b) = a```
222+ class (Semiring a) <= ModuloSemiring a where
186 (/) :: a -> a -> a
223 (/) :: a -> a -> a
226+ -- | Addition, multiplication, and subtraction
227+ class (Semiring a) <= Ring a where
187− (%) :: a -> a -> a
228+ (-) :: a -> a -> a
188− negate :: a -> a
230+ negate :: forall a. (Ring a) => a -> a
189−
231+ negate a = zero - a
233+ -- | Ring where every nonzero element has a multiplicative inverse (possibly
234+ -- | a non-commutative field) so that ```a `mod` b = zero```
235+ class (Ring a, ModuloSemiring a) <= DivisionRing a
237+ -- | A commutative field
238+ class (DivisionRing a) <= Num a
190− foreign import numAdd "function numAdd(n1) {\
240+ foreign import numAdd
242+ function numAdd(n1) {
191− \ return function(n2) {\
243+ return function(n2) {
192− \ return n1 + n2;\
244+ return n1 + n2;
194− \}" :: Number -> Number -> Number
247+ """ :: Number -> Number -> Number
196− foreign import numSub "function numSub(n1) {\
249+ foreign import numSub
251+ function numSub(n1) {
197− \ return function(n2) {\
252+ return function(n2) {
198− \ return n1 - n2;\
253+ return n1 - n2;
200− \}" :: Number -> Number -> Number
256+ """ :: Number -> Number -> Number
202− foreign import numMul "function numMul(n1) {\
258+ foreign import numMul
260+ function numMul(n1) {
203− \ return function(n2) {\
261+ return function(n2) {
204− \ return n1 * n2;\
262+ return n1 * n2;
206− \}" :: Number -> Number -> Number
265+ """ :: Number -> Number -> Number
208− foreign import numDiv "function numDiv(n1) {\
267+ foreign import numDiv
269+ function numDiv(n1) {
209− \ return function(n2) {\
270+ return function(n2) {
210− \ return n1 / n2;\
271+ return n1 / n2;
212− \}" :: Number -> Number -> Number
274+ """ :: Number -> Number -> Number
214− foreign import numMod "function numMod(n1) {\
276+ foreign import numMod
278+ function numMod(n1) {
215− \ return function(n2) {\
279+ return function(n2) {
216− \ return n1 % n2;\
280+ return n1 % n2;
218− \}" :: Number -> Number -> Number
283+ """ :: Number -> Number -> Number
220− foreign import numNegate "function numNegate(n) {\
285+ (%) = numMod
222− \}" :: Number -> Number
224− instance numNumber :: Num Number where
287+ instance semiringNumber :: Semiring Number where
225 (+) = numAdd
288 (+) = numAdd
226− (-) = numSub
289+ zero = 0
227 (*) = numMul
290 (*) = numMul
293+ instance ringNumber :: Ring Number where
296+ instance moduloSemiringNumber :: ModuloSemiring Number where
228 (/) = numDiv
297 (/) = numDiv
229− (%) = numMod
298+ mod _ _ = 0
230− negate = numNegate
299+
300+ instance divisionRingNumber :: DivisionRing Number
302+ instance numNumber :: Num Number
232 newtype Unit = Unit {}
304 newtype Unit = Unit {}
@@ -242,18 +314,22 @@ module Prelude
242 (/=) :: a -> a -> Boolean
314 (/=) :: a -> a -> Boolean
244 foreign import refEq
316 foreign import refEq
245− "function refEq(r1) {\
318+ function refEq(r1) {
246− \ return function(r2) {\
319+ return function(r2) {
247− \ return r1 === r2;\
320+ return r1 === r2;
249− \}" :: forall a. a -> a -> Boolean
323+ """ :: forall a. a -> a -> Boolean
251 foreign import refIneq
325 foreign import refIneq
252− "function refIneq(r1) {\
327+ function refIneq(r1) {
253− \ return function(r2) {\
328+ return function(r2) {
254− \ return r1 !== r2;\
329+ return r1 !== r2;
256− \}" :: forall a. a -> a -> Boolean
332+ """ :: forall a. a -> a -> Boolean
258 instance eqUnit :: Eq Unit where
334 instance eqUnit :: Eq Unit where
259 (==) (Unit {}) (Unit {}) = true
335 (==) (Unit {}) (Unit {}) = true
@@ -272,17 +348,19 @@ module Prelude
272 (/=) = refIneq
348 (/=) = refIneq
274 foreign import eqArrayImpl
350 foreign import eqArrayImpl
275− "function eqArrayImpl(f) {\
352+ function eqArrayImpl(f) {
276− \ return function(xs) {\
353+ return function(xs) {
277− \ return function(ys) {\
354+ return function(ys) {
278− \ if (xs.length !== ys.length) return false;\
355+ if (xs.length !== ys.length) return false;
279− \ for (var i = 0; i < xs.length; i++) {\
356+ for (var i = 0; i < xs.length; i++) {
280− \ if (!f(xs[i])(ys[i])) return false;\
357+ if (!f(xs[i])(ys[i])) return false;
282− \ return true;\
359+ return true;
285− \}" :: forall a. (a -> a -> Boolean) -> [a] -> [a] -> Boolean
363+ """ :: forall a. (a -> a -> Boolean) -> [a] -> [a] -> Boolean
287 instance eqArray :: (Eq a) => Eq [a] where
365 instance eqArray :: (Eq a) => Eq [a] where
288 (==) xs ys = eqArrayImpl (==) xs ys
366 (==) xs ys = eqArrayImpl (==) xs ys
@@ -334,17 +412,19 @@ module Prelude
334 _ -> true
412 _ -> true
336 foreign import unsafeCompareImpl
414 foreign import unsafeCompareImpl
337− "function unsafeCompareImpl(lt) {\
416+ function unsafeCompareImpl(lt) {
338− \ return function(eq) {\
417+ return function(eq) {
339− \ return function(gt) {\
418+ return function(gt) {
340− \ return function(x) {\
419+ return function(x) {
341− \ return function(y) {\
420+ return function(y) {
342− \ return x < y ? lt : x > y ? gt : eq;\
421+ return x < y ? lt : x > y ? gt : eq;
347− \}" :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
427+ """ :: forall a. Ordering -> Ordering -> Ordering -> a -> a -> Ordering
349 unsafeCompare :: forall a. a -> a -> Ordering
429 unsafeCompare :: forall a. a -> a -> Ordering
350 unsafeCompare = unsafeCompareImpl LT EQ GT
430 unsafeCompare = unsafeCompareImpl LT EQ GT
@@ -385,45 +465,66 @@ module Prelude
385 zshr :: b -> Number -> b
465 zshr :: b -> Number -> b
386 complement :: b -> b
466 complement :: b -> b
388− foreign import numShl "function numShl(n1) {\
468+ foreign import numShl
470+ function numShl(n1) {
389− \ return function(n2) {\
471+ return function(n2) {
390− \ return n1 << n2;\
472+ return n1 << n2;
392− \}" :: Number -> Number -> Number
475+ """ :: Number -> Number -> Number
394− foreign import numShr "function numShr(n1) {\
477+ foreign import numShr
479+ function numShr(n1) {
395− \ return function(n2) {\
480+ return function(n2) {
396− \ return n1 >> n2;\
481+ return n1 >> n2;
398− \}" :: Number -> Number -> Number
484+ """ :: Number -> Number -> Number
400− foreign import numZshr "function numZshr(n1) {\
486+ foreign import numZshr
488+ function numZshr(n1) {
401− \ return function(n2) {\
489+ return function(n2) {
402− \ return n1 >>> n2;\
490+ return n1 >>> n2;
404− \}" :: Number -> Number -> Number
493+ """ :: Number -> Number -> Number
406− foreign import numAnd "function numAnd(n1) {\
495+ foreign import numAnd
497+ function numAnd(n1) {
407− \ return function(n2) {\
498+ return function(n2) {
408− \ return n1 & n2;\
499+ return n1 & n2;
410− \}" :: Number -> Number -> Number
502+ """ :: Number -> Number -> Number
412− foreign import numOr "function numOr(n1) {\
504+ foreign import numOr
506+ function numOr(n1) {
413− \ return function(n2) {\
507+ return function(n2) {
414− \ return n1 | n2;\
508+ return n1 | n2;
416− \}" :: Number -> Number -> Number
511+ """ :: Number -> Number -> Number
418− foreign import numXor "function numXor(n1) {\
513+ foreign import numXor
515+ function numXor(n1) {
419− \ return function(n2) {\
516+ return function(n2) {
420− \ return n1 ^ n2;\
517+ return n1 ^ n2;
422− \}" :: Number -> Number -> Number
520+ """ :: Number -> Number -> Number
424− foreign import numComplement "function numComplement(n) {\
522+ foreign import numComplement
524+ function numComplement(n) {
425− \ return ~n;\
525+ return ~n;
426− \}" :: Number -> Number
527+ """ :: Number -> Number
428 instance bitsNumber :: Bits Number where
529 instance bitsNumber :: Bits Number where
429 (.&.) = numAnd
530 (.&.) = numAnd
@@ -442,21 +543,30 @@ module Prelude
442 (||) :: b -> b -> b
543 (||) :: b -> b -> b
443 not :: b -> b
544 not :: b -> b
445− foreign import boolAnd "function boolAnd(b1) {\
546+ foreign import boolAnd
548+ function boolAnd(b1) {
446− \ return function(b2) {\
549+ return function(b2) {
447− \ return b1 && b2;\
550+ return b1 && b2;
449− \}" :: Boolean -> Boolean -> Boolean
553+ """ :: Boolean -> Boolean -> Boolean
451− foreign import boolOr "function boolOr(b1) {\
555+ foreign import boolOr
557+ function boolOr(b1) {
452− \ return function(b2) {\
558+ return function(b2) {
453− \ return b1 || b2;\
559+ return b1 || b2;
455− \}" :: Boolean -> Boolean -> Boolean
562+ """ :: Boolean -> Boolean -> Boolean
457− foreign import boolNot "function boolNot(b) {\
564+ foreign import boolNot
566+ function boolNot(b) {
458− \ return !b;\
567+ return !b;
459− \}" :: Boolean -> Boolean
569+ """ :: Boolean -> Boolean
461 instance boolLikeBoolean :: BoolLike Boolean where
571 instance boolLikeBoolean :: BoolLike Boolean where
462 (&&) = boolAnd
572 (&&) = boolAnd
@@ -469,11 +579,13 @@ module Prelude
469 (<>) :: a -> a -> a
579 (<>) :: a -> a -> a
471 foreign import concatString
581 foreign import concatString
472− "function concatString(s1) {\
583+ function concatString(s1) {
473− \ return function(s2) {\
584+ return function(s2) {
474− \ return s1 + s2;\
585+ return s1 + s2;
476− \}" :: String -> String -> String
588+ """ :: String -> String -> String
478 instance semigroupUnit :: Semigroup Unit where
590 instance semigroupUnit :: Semigroup Unit where
479 (<>) (Unit {}) (Unit {}) = Unit {}
591 (<>) (Unit {}) (Unit {}) = Unit {}
@@ -507,293 +619,334 @@ module Data.Function where
507 foreign import data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
619 foreign import data Fn10 :: * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> * -> *
509 foreign import mkFn0
621 foreign import mkFn0
510− "function mkFn0(fn) {\
623+ function mkFn0(fn) {
511− \ return function() {\
624+ return function() {
512− \ return fn({});\
625+ return fn({});
514− \}" :: forall a. (Unit -> a) -> Fn0 a
628+ """ :: forall a. (Unit -> a) -> Fn0 a
516 foreign import mkFn1
630 foreign import mkFn1
517− "function mkFn1(fn) {\
632+ function mkFn1(fn) {
518− \ return function(a) {\
633+ return function(a) {
519− \ return fn(a);\
634+ return fn(a);
521− \}" :: forall a b. (a -> b) -> Fn1 a b
637+ """ :: forall a b. (a -> b) -> Fn1 a b
523 foreign import mkFn2
639 foreign import mkFn2
524− "function mkFn2(fn) {\
641+ function mkFn2(fn) {
525− \ return function(a, b) {\
642+ return function(a, b) {
526− \ return fn(a)(b);\
643+ return fn(a)(b);
528− \}" :: forall a b c. (a -> b -> c) -> Fn2 a b c
646+ """ :: forall a b c. (a -> b -> c) -> Fn2 a b c
530 foreign import mkFn3
648 foreign import mkFn3
531− "function mkFn3(fn) {\
650+ function mkFn3(fn) {
532− \ return function(a, b, c) {\
651+ return function(a, b, c) {
533− \ return fn(a)(b)(c);\
652+ return fn(a)(b)(c);
535− \}" :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d
655+ """ :: forall a b c d. (a -> b -> c -> d) -> Fn3 a b c d
537 foreign import mkFn4
657 foreign import mkFn4
538− "function mkFn4(fn) {\
659+ function mkFn4(fn) {
539− \ return function(a, b, c, d) {\
660+ return function(a, b, c, d) {
540− \ return fn(a)(b)(c)(d);\
661+ return fn(a)(b)(c)(d);
542− \}" :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e
664+ """ :: forall a b c d e. (a -> b -> c -> d -> e) -> Fn4 a b c d e
544 foreign import mkFn5
666 foreign import mkFn5
545− "function mkFn5(fn) {\
668+ function mkFn5(fn) {
546− \ return function(a, b, c, d, e) {\
669+ return function(a, b, c, d, e) {
547− \ return fn(a)(b)(c)(d)(e);\
670+ return fn(a)(b)(c)(d)(e);
549− \}" :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f
673+ """ :: forall a b c d e f. (a -> b -> c -> d -> e -> f) -> Fn5 a b c d e f
551 foreign import mkFn6
675 foreign import mkFn6
552− "function mkFn6(fn) {\
677+ function mkFn6(fn) {
553− \ return function(a, b, c, d, e, f) {\
678+ return function(a, b, c, d, e, f) {
554− \ return fn(a)(b)(c)(d)(e)(f);\
679+ return fn(a)(b)(c)(d)(e)(f);
556− \}" :: forall a b c d e f g. (a -> b -> c -> d -> e -> f -> g) -> Fn6 a b c d e f g
682+ """ :: forall a b c d e f g. (a -> b -> c -> d -> e -> f -> g) -> Fn6 a b c d e f g
558 foreign import mkFn7
684 foreign import mkFn7
559− "function mkFn7(fn) {\
686+ function mkFn7(fn) {
560− \ return function(a, b, c, d, e, f, g) {\
687+ return function(a, b, c, d, e, f, g) {
561− \ return fn(a)(b)(c)(d)(e)(f)(g);\
688+ return fn(a)(b)(c)(d)(e)(f)(g);
563− \}" :: 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+ """ :: 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
565 foreign import mkFn8
693 foreign import mkFn8
566− "function mkFn8(fn) {\
695+ function mkFn8(fn) {
567− \ return function(a, b, c, d, e, f, g, h) {\
696+ return function(a, b, c, d, e, f, g, h) {
568− \ return fn(a)(b)(c)(d)(e)(f)(g)(h);\
697+ return fn(a)(b)(c)(d)(e)(f)(g)(h);
570− \}" :: 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+ """ :: 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
572 foreign import mkFn9
702 foreign import mkFn9
573− "function mkFn9(fn) {\
704+ function mkFn9(fn) {
574− \ return function(a, b, c, d, e, f, g, h, i) {\
705+ return function(a, b, c, d, e, f, g, h, i) {
575− \ return fn(a)(b)(c)(d)(e)(f)(g)(h)(i);\
706+ return fn(a)(b)(c)(d)(e)(f)(g)(h)(i);
577− \}" :: 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+ """ :: 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
579 foreign import mkFn10
711 foreign import mkFn10
580− "function mkFn10(fn) {\
713+ function mkFn10(fn) {
581− \ return function(a, b, c, d, e, f, g, h, i, j) {\
714+ return function(a, b, c, d, e, f, g, h, i, j) {
582− \ return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(j);\
715+ return fn(a)(b)(c)(d)(e)(f)(g)(h)(i)(j);
584− \}" :: 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+ """ :: 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
586 foreign import runFn0
720 foreign import runFn0
587− "function runFn0(fn) {\
722+ function runFn0(fn) {
588− \ return fn();\
723+ return fn();
589− \}" :: forall a. Fn0 a -> a
725+ """ :: forall a. Fn0 a -> a
591 foreign import runFn1
727 foreign import runFn1
592− "function runFn1(fn) {\
729+ function runFn1(fn) {
593− \ return function(a) {\
730+ return function(a) {
594− \ return fn(a);\
731+ return fn(a);
596− \}" :: forall a b. Fn1 a b -> a -> b
734+ """ :: forall a b. Fn1 a b -> a -> b
598 foreign import runFn2
736 foreign import runFn2
599− "function runFn2(fn) {\
738+ function runFn2(fn) {
600− \ return function(a) {\
739+ return function(a) {
601− \ return function(b) {\
740+ return function(b) {
602− \ return fn(a, b);\
741+ return fn(a, b);
605− \}" :: forall a b c. Fn2 a b c -> a -> b -> c
745+ """ :: forall a b c. Fn2 a b c -> a -> b -> c
607 foreign import runFn3
747 foreign import runFn3
608− "function runFn3(fn) {\
749+ function runFn3(fn) {
609− \ return function(a) {\
750+ return function(a) {
610− \ return function(b) {\
751+ return function(b) {
611− \ return function(c) {\
752+ return function(c) {
612− \ return fn(a, b, c);\
753+ return fn(a, b, c);
616− \}" :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d
758+ """ :: forall a b c d. Fn3 a b c d -> a -> b -> c -> d
618 foreign import runFn4
760 foreign import runFn4
619− "function runFn4(fn) {\
762+ function runFn4(fn) {
620− \ return function(a) {\
763+ return function(a) {
621− \ return function(b) {\
764+ return function(b) {
622− \ return function(c) {\
765+ return function(c) {
623− \ return function(d) {\
766+ return function(d) {
624− \ return fn(a, b, c, d);\
767+ return fn(a, b, c, d);
629− \}" :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e
773+ """ :: forall a b c d e. Fn4 a b c d e -> a -> b -> c -> d -> e
631 foreign import runFn5
775 foreign import runFn5
632− "function runFn5(fn) {\
777+ function runFn5(fn) {
633− \ return function(a) {\
778+ return function(a) {
634− \ return function(b) {\
779+ return function(b) {
635− \ return function(c) {\
780+ return function(c) {
636− \ return function(d) {\
781+ return function(d) {
637− \ return function(e) {\
782+ return function(e) {
638− \ return fn(a, b, c, d, e);\
783+ return fn(a, b, c, d, e);
644− \}" :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f
790+ """ :: forall a b c d e f. Fn5 a b c d e f -> a -> b -> c -> d -> e -> f
646 foreign import runFn6
792 foreign import runFn6
647− "function runFn6(fn) {\
794+ function runFn6(fn) {
648− \ return function(a) {\
795+ return function(a) {
649− \ return function(b) {\
796+ return function(b) {
650− \ return function(c) {\
797+ return function(c) {
651− \ return function(d) {\
798+ return function(d) {
652− \ return function(e) {\
799+ return function(e) {
653− \ return function(f) {\
800+ return function(f) {
654− \ return fn(a, b, c, d, e, f);\
801+ return fn(a, b, c, d, e, f);
661− \}" :: forall a b c d e f g. Fn6 a b c d e f g -> a -> b -> c -> d -> e -> f -> g
809+ """ :: forall a b c d e f g. Fn6 a b c d e f g -> a -> b -> c -> d -> e -> f -> g
663 foreign import runFn7
811 foreign import runFn7
664− "function runFn7(fn) {\
813+ function runFn7(fn) {
665− \ return function(a) {\
814+ return function(a) {
666− \ return function(b) {\
815+ return function(b) {
667− \ return function(c) {\
816+ return function(c) {
668− \ return function(d) {\
817+ return function(d) {
669− \ return function(e) {\
818+ return function(e) {
670− \ return function(f) {\
819+ return function(f) {
671− \ return function(g) {\
820+ return function(g) {
672− \ return fn(a, b, c, d, e, f, g);\
821+ return fn(a, b, c, d, e, f, g);
680− \}" :: 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+ """ :: 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
682 foreign import runFn8
832 foreign import runFn8
683− "function runFn8(fn) {\
834+ function runFn8(fn) {
684− \ return function(a) {\
835+ return function(a) {
685− \ return function(b) {\
836+ return function(b) {
686− \ return function(c) {\
837+ return function(c) {
687− \ return function(d) {\
838+ return function(d) {
688− \ return function(e) {\
839+ return function(e) {
689− \ return function(f) {\
840+ return function(f) {
690− \ return function(g) {\
841+ return function(g) {
691− \ return function(h) {\
842+ return function(h) {
692− \ return fn(a, b, c, d, e, f, g, h);\
843+ return fn(a, b, c, d, e, f, g, h);
701− \}" :: 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+ """ :: 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
703 foreign import runFn9
855 foreign import runFn9
704− "function runFn9(fn) {\
857+ function runFn9(fn) {
705− \ return function(a) {\
858+ return function(a) {
706− \ return function(b) {\
859+ return function(b) {
707− \ return function(c) {\
860+ return function(c) {
708− \ return function(d) {\
861+ return function(d) {
709− \ return function(e) {\
862+ return function(e) {
710− \ return function(f) {\
863+ return function(f) {
711− \ return function(g) {\
864+ return function(g) {
712− \ return function(h) {\
865+ return function(h) {
713− \ return function(i) {\
866+ return function(i) {
714− \ return fn(a, b, c, d, e, f, g, h, i);\
867+ return fn(a, b, c, d, e, f, g, h, i);
724− \}" :: 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+ """ :: 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
726 foreign import runFn10
880 foreign import runFn10
727− "function runFn10(fn) {\
882+ function runFn10(fn) {
728− \ return function(a) {\
883+ return function(a) {
729− \ return function(b) {\
884+ return function(b) {
730− \ return function(c) {\
885+ return function(c) {
731− \ return function(d) {\
886+ return function(d) {
732− \ return function(e) {\
887+ return function(e) {
733− \ return function(f) {\
888+ return function(f) {
734− \ return function(g) {\
889+ return function(g) {
735− \ return function(h) {\
890+ return function(h) {
736− \ return function(i) {\
891+ return function(i) {
737− \ return function(j) {\
892+ return function(j) {
738− \ return fn(a, b, c, d, e, f, g, h, i, j);\
893+ return fn(a, b, c, d, e, f, g, h, i, j);
749− \}" :: 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+ """ :: 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
753− newtype Ref a = Ref a
755− liftRef :: forall a b. (a -> a -> b) -> Ref a -> Ref a -> b
756− liftRef f (Ref x) (Ref y) = f x y
758− instance eqRef :: Eq (Ref a) where
759− (==) = liftRef refEq
760− (/=) = liftRef refIneq
762− instance functorRef :: Functor Ref where
763− (<$>) f (Ref x) = Ref (f x)
765module Prelude.Unsafe where
907module Prelude.Unsafe where
767 foreign import unsafeIndex
909 foreign import unsafeIndex
768− "function unsafeIndex(xs) {\
911+ function unsafeIndex(xs) {
769− \ return function(n) {\
912+ return function(n) {
770− \ return xs[n];\
913+ return xs[n];
772− \}" :: forall a. [a] -> Number -> a
916+ """ :: forall a. [a] -> Number -> a
774module Control.Monad.Eff where
918module Control.Monad.Eff where
776 foreign import data Eff :: # ! -> * -> *
920 foreign import data Eff :: # ! -> * -> *
778− foreign import returnE "function returnE(a) {\
922+ foreign import returnE
924+ function returnE(a) {
779− \ return function() {\
925+ return function() {
780− \ return a;\
926+ return a;
782− \}" :: forall e a. a -> Eff e a
929+ """ :: forall e a. a -> Eff e a
784− foreign import bindE "function bindE(a) {\
931+ foreign import bindE
785− \ return function(f) {\
934+ return function(f) {
786− \ return function() {\
935+ return function() {
787− \ return f(a())();\
936+ return f(a())();
790− \}" :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
940+ """ :: forall e a b. Eff e a -> (a -> Eff e b) -> Eff e b
792 type Pure a = forall e. Eff e a
942 type Pure a = forall e. Eff e a
794− foreign import runPure "function runPure(f) {\
944+ foreign import runPure
946+ function runPure(f) {
795− \ return f();\
947+ return f();
796− \}" :: forall a. Pure a -> a
949+ """ :: forall a. Pure a -> a
798 instance functorEff :: Functor (Eff e) where
951 instance functorEff :: Functor (Eff e) where
799 (<$>) = liftA1
952 (<$>) = liftA1
@@ -809,55 +962,69 @@ module Control.Monad.Eff where
810 instance monadEff :: Monad (Eff e)
963 instance monadEff :: Monad (Eff e)
812− foreign import untilE "function untilE(f) {\
965+ foreign import untilE
967+ function untilE(f) {
813− \ return function() {\
968+ return function() {
814− \ while (!f());\
969+ while (!f());
815− \ return {};\
970+ return {};
817− \}" :: forall e. Eff e Boolean -> Eff e Unit
973+ """ :: forall e. Eff e Boolean -> Eff e Unit
819− foreign import whileE "function whileE(f) {\
975+ foreign import whileE
977+ function whileE(f) {
820− \ return function(a) {\
978+ return function(a) {
821− \ return function() {\
979+ return function() {
822− \ while (f()) {\
980+ while (f()) {
825− \ return {};\
983+ return {};
828− \}" :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
987+ """ :: forall e a. Eff e Boolean -> Eff e a -> Eff e Unit
830− foreign import forE "function forE(lo) {\
989+ foreign import forE
831− \ return function(hi) {\
992+ return function(hi) {
832− \ return function(f) {\
993+ return function(f) {
833− \ return function() {\
994+ return function() {
834− \ for (var i = lo; i < hi; i++) {\
995+ for (var i = lo; i < hi; i++) {
835− \ f(i)();\
996+ f(i)();
840− \}" :: forall e. Number -> Number -> (Number -> Eff e Unit) -> Eff e Unit
1002+ """ :: forall e. Number -> Number -> (Number -> Eff e Unit) -> Eff e Unit
843− foreign import foreachE "function foreachE(as) {\
1005+ foreign import foreachE
1007+ function foreachE(as) {
844− \ return function(f) {\
1008+ return function(f) {
845− \ return function() {\
1009+ return function() {
846− \ for (var i = 0; i < as.length; i++) {\
1010+ for (var i = 0; i < as.length; i++) {
847− \ f(as[i])();\
1011+ f(as[i])();
851− \}" :: forall e a. [a] -> (a -> Eff e Unit) -> Eff e Unit
1016+ """ :: forall e a. [a] -> (a -> Eff e Unit) -> Eff e Unit
853module Control.Monad.Eff.Unsafe where
1018module Control.Monad.Eff.Unsafe where
855 import Control.Monad.Eff
1020 import Control.Monad.Eff
857 foreign import unsafeInterleaveEff
1022 foreign import unsafeInterleaveEff
858− "function unsafeInterleaveEff(f) {\
1024+ function unsafeInterleaveEff(f) {
859− \ return f;\
1025+ return f;
860− \}" :: forall eff1 eff2 a. Eff eff1 a -> Eff eff2 a
1027+ """ :: forall eff1 eff2 a. Eff eff1 a -> Eff eff2 a
862module Debug.Trace where
1029module Debug.Trace where
@@ -865,12 +1032,15 @@ module Debug.Trace where
866 foreign import data Trace :: !
1033 foreign import data Trace :: !
868− foreign import trace "function trace(s) {\
1035+ foreign import trace
1037+ function trace(s) {
869− \ return function() {\
1038+ return function() {
870− \ console.log(s);\
1039+ console.log(s);
871− \ return {};\
1040+ return {};
873− \}" :: forall r. String -> Eff (trace :: Trace | r) Unit
1043+ """ :: forall r. String -> Eff (trace :: Trace | r) Unit
875 print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit
1045 print :: forall a r. (Show a) => a -> Eff (trace :: Trace | r) Unit
876 print o = trace (show o)
1046 print o = trace (show o)
@@ -883,37 +1053,52 @@ module Control.Monad.ST where
884 foreign import data STRef :: * -> * -> *
1054 foreign import data STRef :: * -> * -> *
886− foreign import newSTRef "function newSTRef(val) {\
1056+ foreign import newSTRef
1058+ function newSTRef(val) {
887− \ return function() {\
1059+ return function() {
888− \ return { value: val };\
1060+ return { value: val };
890− \}" :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
1063+ """ :: forall a h r. a -> Eff (st :: ST h | r) (STRef h a)
892− foreign import readSTRef "function readSTRef(ref) {\
1065+ foreign import readSTRef
1067+ function readSTRef(ref) {
893− \ return function() {\
1068+ return function() {
894− \ return ref.value;\
1069+ return ref.value;
896− \}" :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
1072+ """ :: forall a h r. STRef h a -> Eff (st :: ST h | r) a
898− foreign import modifySTRef "function modifySTRef(ref) {\
1074+ foreign import modifySTRef
1076+ function modifySTRef(ref) {
899− \ return function(f) {\
1077+ return function(f) {
900− \ return function() {\
1078+ return function() {
901− \ return ref.value = f(ref.value);\
1079+ return ref.value = f(ref.value);
904− \}" :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
1083+ """ :: forall a h r. STRef h a -> (a -> a) -> Eff (st :: ST h | r) a
906− foreign import writeSTRef "function writeSTRef(ref) {\
1085+ foreign import writeSTRef
1087+ function writeSTRef(ref) {
907− \ return function(a) {\
1088+ return function(a) {
908− \ return function() {\
1089+ return function() {
909− \ return ref.value = a;\
1090+ return ref.value = a;
912− \}" :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
1094+ """ :: forall a h r. STRef h a -> a -> Eff (st :: ST h | r) a
914− foreign import runST "function runST(f) {\
1096+ foreign import runST
1098+ function runST(f) {
915− \ return f;\
1099+ return f;
916− \}" :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
1101+ """ :: forall a r. (forall h. Eff (st :: ST h | r) a) -> Eff r a
918 pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
1103 pureST :: forall a. (forall h r. Eff (st :: ST h | r) a) -> a
919 pureST st = runPure (runST st)
1104 pureST st = runPure (runST st)