on master help sign in
Add `plainText` back. Fix some types. Fix a bug in `mergeEither`.
986010fevancz
libraries/Graphics/Text.elm+3
@@ -53,6 +53,9 @@ righted : Text -> Element
53
53
54-- Display styled text.
54-- Display styled text.
55text : Text -> Element
55text : Text -> Element
56+
57+-- Display a plain string.
58+plainText : String -> Element
56
59
57-- Convert anything to it's textual representation and make it displayable in browser
60-- Convert anything to it's textual representation and make it displayable in browser
58-- asText = text . monospace . show
61-- asText = text . monospace . show
libraries/List.elm+4−2
@@ -108,9 +108,11 @@ unzip pairs =
108-- split "," "hello,there,friend" == ["hello", "there", "friend"]
108-- split "," "hello,there,friend" == ["hello", "there", "friend"]
109split : [a] -> [a] -> [[a]]
109split : [a] -> [a] -> [[a]]
110
110
111−-- Places the given value between all of the lists in the second argument and concatenates the result.
111+-- Places the given value between all of the lists in the second argument
112+-- and concatenates the result.
113+--
112-- join xs xss = concat (intersperse xs xss)
114-- join xs xss = concat (intersperse xs xss)
113−join : [a] -> [[a]] -> [a]
115+join : Appendable a -> [Appendable a] -> Appendable a
114
116
115-- Places the given value between all members of the given list.
117-- Places the given value between all members of the given list.
116intersperse : a -> [a] -> [a]
118intersperse : a -> [a] -> [a]
libraries/Native/Graphics/Text.js+5
@@ -106,6 +106,10 @@ Elm.Native.Graphics.Text = function(elm) {
106 return position('left')(monospace(toText(show(v))));
106 return position('left')(monospace(toText(show(v))));
107 }
107 }
108
108
109+ function plainText(v) {
110+ return position('left')(toText(v));
111+ }
112+
109 return elm.Native.Graphics.Text = {
113 return elm.Native.Graphics.Text = {
110 toText: toText,
114 toText: toText,
111
115
@@ -125,6 +129,7 @@ Elm.Native.Graphics.Text = function(elm) {
125 centered : position('center'),
129 centered : position('center'),
126 righted : position('right'),
130 righted : position('right'),
127 text : position('left'),
131 text : position('left'),
132+ plainText : plainText,
128
133
129 asText : asText
134 asText : asText
130 };
135 };
libraries/Native/List.js+3−1
@@ -3,7 +3,8 @@ Elm.Native.List = function(elm) {
3
3
4 elm.Native = elm.Native || {};
4 elm.Native = elm.Native || {};
5 if (elm.Native.List) return elm.Native.List;
5 if (elm.Native.List) return elm.Native.List;
6+ if ('values' in Elm.Native.List)
6− if ('values' in Elm.Native.List) return elm.Native.List = Elm.Native.List.values
7+ return elm.Native.List = Elm.Native.List.values;
7
8
8 var Utils = Elm.Native.Utils(elm);
9 var Utils = Elm.Native.Utils(elm);
9
10
@@ -238,6 +239,7 @@ Elm.Native.List = function(elm) {
238 }
239 }
239
240
240 function join(sep, xss) {
241 function join(sep, xss) {
242+ if (typeof sep === 'string') return toArray(xss).join(sep);
241 if (xss.ctor === 'Nil') return Nil;
243 if (xss.ctor === 'Nil') return Nil;
242 var s = toArray(sep);
244 var s = toArray(sep);
243 var out = toArray(xss._0);
245 var out = toArray(xss._0);
libraries/Native/Signal/Signal.js+3−3
@@ -191,8 +191,8 @@ Elm.Native.Signal = function(elm) {
191
191
192 function merge(s1,s2) { return new Merge(s1,s2) }
192 function merge(s1,s2) { return new Merge(s1,s2) }
193 function merges(ss) { return A2(foldl1, F2(merge), ss) }
193 function merges(ss) { return A2(foldl1, F2(merge), ss) }
194− function mergeEither(s1,s2) {return new Merge(A2(lift, Either.Left , s1),
194+ function mergeEither(s1,s2) { return new Merge(lift(Either.Left, s1),
195− A2(lift, Either.Right, s2))}
195+ lift(Either.Right,s2)) }
196
196
197 function average(sampleSize, s) {
197 function average(sampleSize, s) {
198 var sample = new Array(sampleSize);
198 var sample = new Array(sampleSize);
@@ -222,7 +222,7 @@ Elm.Native.Signal = function(elm) {
222 lift7 : F8(lift7),
222 lift7 : F8(lift7),
223 lift8 : F9(lift8),
223 lift8 : F9(lift8),
224 foldp : F3(foldp),
224 foldp : F3(foldp),
225− delay : delay,
225+ delay : F2(delay),
226 merge : F2(merge),
226 merge : F2(merge),
227 merges : merges,
227 merges : merges,
228 mergeEither : F2(mergeEither),
228 mergeEither : F2(mergeEither),
libraries/Native/Signal/Time.js+3−2
@@ -4,6 +4,7 @@ Elm.Native.Time = function(elm) {
4
4
5 var Signal = Elm.Signal(elm);
5 var Signal = Elm.Signal(elm);
6 var Maybe = Elm.Maybe(elm);
6 var Maybe = Elm.Maybe(elm);
7+ var Utils = Elm.Native.Utils(elm);
7
8
8 function fpsWhen(desiredFPS, isOn) {
9 function fpsWhen(desiredFPS, isOn) {
9 var msPerFrame = 1000 / desiredFPS;
10 var msPerFrame = 1000 / desiredFPS;
@@ -37,8 +38,8 @@ Elm.Native.Time = function(elm) {
37 }
38 }
38
39
39 function since(t, s) {
40 function since(t, s) {
40− function cmp(a,b) { return !Value.eq(a,b) }
41+ function cmp(a,b) { return !Utils.eq(a,b) }
41− var dcount = Signal.count(Signal.delay(t)(s));
42+ var dcount = Signal.count(A2(Signal.delay, t, s));
42 return A3( Signal.lift2, F2(cmp), Signal.count(s), dcount );
43 return A3( Signal.lift2, F2(cmp), Signal.count(s), dcount );
43 }
44 }
44 function after(t) {
45 function after(t) {
libraries/Time.elm+2−2
@@ -36,14 +36,14 @@ inHours t = t / hour
36-- gives a sequence of time deltas as quickly as possible until it reaches
36-- gives a sequence of time deltas as quickly as possible until it reaches
37-- the desired FPS. A time delta is the time between the last frame and the
37-- the desired FPS. A time delta is the time between the last frame and the
38-- current frame.
38-- current frame.
39−fps : Number -> Signal Time
39+fps : Number a -> Signal Time
40
40
41-- Same as the fps function, but you can turn it on and off. Allows you
41-- Same as the fps function, but you can turn it on and off. Allows you
42-- to do brief animations based on user input without major ineffeciencies.
42-- to do brief animations based on user input without major ineffeciencies.
43-- The first time delta after a pause is always zero, no matter how long
43-- The first time delta after a pause is always zero, no matter how long
44-- the pause was. This way summing the deltas will actually give the amount
44-- the pause was. This way summing the deltas will actually give the amount
45-- of time that the output signal has been running.
45-- of time that the output signal has been running.
46−fpsWhen : Number -> Signal Bool -> Signal Time
46+fpsWhen : Number a -> Signal Bool -> Signal Time
47
47
48-- Takes a time interval t. The resulting signal is the current time,
48-- Takes a time interval t. The resulting signal is the current time,
49-- updated every t.
49-- updated every t.