on master help sign in
Move some library functions out of JS and into Elm
a3ba3d3Evan Czaplicki
libraries/Basics.elm+4−4
@@ -311,11 +311,11 @@ id x = x
311
311
312{-| Given a 2-tuple, returns the first value. -}
312{-| Given a 2-tuple, returns the first value. -}
313fst : (a,b) -> a
313fst : (a,b) -> a
314−fst = Native.Basics.fst
314+fst (a,_) = a
315
315
316{-| Given a 2-tuple, returns the second value. -}
316{-| Given a 2-tuple, returns the second value. -}
317snd : (a,b) -> b
317snd : (a,b) -> b
318−snd = Native.Basics.snd
318+snd (_,b) = b
319
319
320{-| Flips the order of the first two arguments to a function. -}
320{-| Flips the order of the first two arguments to a function. -}
321flip : (a -> b -> c) -> (b -> a -> c)
321flip : (a -> b -> c) -> (b -> a -> c)
@@ -325,10 +325,10 @@ flip f b a = f a b
325This splits paired arguments into two separate arguments.
325This splits paired arguments into two separate arguments.
326-}
326-}
327curry : ((a,b) -> c) -> a -> b -> c
327curry : ((a,b) -> c) -> a -> b -> c
328−curry = Native.Basics.curry
328+curry f a b = f (a,b)
329
329
330{-| Change how arguments are passed to a function.
330{-| Change how arguments are passed to a function.
331This combines two arguments into a sigle pair.
331This combines two arguments into a sigle pair.
332-}
332-}
333uncurry : (a -> b -> c) -> (a,b) -> c
333uncurry : (a -> b -> c) -> (a,b) -> c
334−uncurry = Native.Basics.uncurry
334+uncurry f (a,b) = f a b
libraries/Native/Basics.js−10
@@ -22,11 +22,6 @@ Elm.Native.Basics.make = function(elm) {
22
22
23 function truncate(n) { return n|0; }
23 function truncate(n) { return n|0; }
24
24
25− function curry(f,a,b) { return f(Utils.Tuple2(a,b)); }
26− function uncurry(f,v) { return A2(f,v._0,v._1); }
27− function fst(t) { return t._0; }
28− function snd(t) { return t._1; }
29−
30 var basics = {
25 var basics = {
31 div:F2(div),
26 div:F2(div),
32 rem:F2(rem),
27 rem:F2(rem),
@@ -58,11 +53,6 @@ Elm.Native.Basics.make = function(elm) {
58 floor:Math.floor,
53 floor:Math.floor,
59 round:Math.round,
54 round:Math.round,
60 toFloat:function(x) { return x; },
55 toFloat:function(x) { return x; },
61−
62− curry:F3(curry),
63− uncurry:F2(uncurry),
64− fst:fst,
65− snd:snd
66 };
56 };
67
57
68 return elm.Native.Basics.values = basics;
58 return elm.Native.Basics.values = basics;