on master help sign in
Add `plainText` back. Fix some types. Fix a bug in `mergeEither`.
commit986010fb6abb99fcae9d139202046257e7d15886 authorevancz <info@elm-lang.org> dateWed 10 Apr 2013, 00:52 (14 years ago) parent82b7929
7 files changed+23−10
libraries/Graphics/Text.elm+3 libraries/List.elm+4−2 libraries/Native/Graphics/Text.js+5 libraries/Native/List.js+3−1 libraries/Native/Signal/Signal.js+3−3 libraries/Native/Signal/Time.js+3−2 libraries/Time.elm+2−2
libraries/Graphics/Text.elm+3
@@ -53,6 +53,9 @@ righted : Text -> Element
5353
5454-- Display styled text.
5555text : Text -> Element
56+
57+-- Display a plain string.
58+plainText : String -> Element
5659
5760-- Convert anything to it's textual representation and make it displayable in browser
5861-- asText = text . monospace . show
libraries/List.elm+4−2
@@ -108,9 +108,11 @@ unzip pairs =
108108-- split "," "hello,there,friend" == ["hello", "there", "friend"]
109109split : [a] -> [a] -> [[a]]
110110
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+--
112114-- join xs xss = concat (intersperse xs xss)
113−join : [a] -> [[a]] -> [a]
115+join : Appendable a -> [Appendable a] -> Appendable a
114116
115117-- Places the given value between all members of the given list.
116118intersperse : a -> [a] -> [a]
libraries/Native/Graphics/Text.js+5
@@ -106,6 +106,10 @@ Elm.Native.Graphics.Text = function(elm) {
106106 return position('left')(monospace(toText(show(v))));
107107 }
108108
109+ function plainText(v) {
110+ return position('left')(toText(v));
111+ }
112+
109113 return elm.Native.Graphics.Text = {
110114 toText: toText,
111115
@@ -125,6 +129,7 @@ Elm.Native.Graphics.Text = function(elm) {
125129 centered : position('center'),
126130 righted : position('right'),
127131 text : position('left'),
132+ plainText : plainText,
128133
129134 asText : asText
130135 };
libraries/Native/List.js+3−1
@@ -3,7 +3,8 @@ Elm.Native.List = function(elm) {
33
44 elm.Native = elm.Native || {};
55 if (elm.Native.List) return elm.Native.List;
6− if ('values' in Elm.Native.List) return elm.Native.List = Elm.Native.List.values
6+ if ('values' in Elm.Native.List)
7+ return elm.Native.List = Elm.Native.List.values;
78
89 var Utils = Elm.Native.Utils(elm);
910
@@ -238,6 +239,7 @@ Elm.Native.List = function(elm) {
238239 }
239240
240241 function join(sep, xss) {
242+ if (typeof sep === 'string') return toArray(xss).join(sep);
241243 if (xss.ctor === 'Nil') return Nil;
242244 var s = toArray(sep);
243245 var out = toArray(xss._0);
libraries/Native/Signal/Signal.js+3−3
@@ -191,8 +191,8 @@ Elm.Native.Signal = function(elm) {
191191
192192 function merge(s1,s2) { return new Merge(s1,s2) }
193193 function merges(ss) { return A2(foldl1, F2(merge), ss) }
194− function mergeEither(s1,s2) {return new Merge(A2(lift, Either.Left , s1),
195− A2(lift, Either.Right, s2))}
194+ function mergeEither(s1,s2) { return new Merge(lift(Either.Left, s1),
195+ lift(Either.Right,s2)) }
196196
197197 function average(sampleSize, s) {
198198 var sample = new Array(sampleSize);
@@ -222,7 +222,7 @@ Elm.Native.Signal = function(elm) {
222222 lift7 : F8(lift7),
223223 lift8 : F9(lift8),
224224 foldp : F3(foldp),
225− delay : delay,
225+ delay : F2(delay),
226226 merge : F2(merge),
227227 merges : merges,
228228 mergeEither : F2(mergeEither),
libraries/Native/Signal/Time.js+3−2
@@ -4,6 +4,7 @@ Elm.Native.Time = function(elm) {
44
55 var Signal = Elm.Signal(elm);
66 var Maybe = Elm.Maybe(elm);
7+ var Utils = Elm.Native.Utils(elm);
78
89 function fpsWhen(desiredFPS, isOn) {
910 var msPerFrame = 1000 / desiredFPS;
@@ -37,8 +38,8 @@ Elm.Native.Time = function(elm) {
3738 }
3839
3940 function since(t, s) {
40− function cmp(a,b) { return !Value.eq(a,b) }
41− var dcount = Signal.count(Signal.delay(t)(s));
41+ function cmp(a,b) { return !Utils.eq(a,b) }
42+ var dcount = Signal.count(A2(Signal.delay, t, s));
4243 return A3( Signal.lift2, F2(cmp), Signal.count(s), dcount );
4344 }
4445 function after(t) {
libraries/Time.elm+2−2
@@ -36,14 +36,14 @@ inHours t = t / hour
3636-- gives a sequence of time deltas as quickly as possible until it reaches
3737-- the desired FPS. A time delta is the time between the last frame and the
3838-- current frame.
39−fps : Number -> Signal Time
39+fps : Number a -> Signal Time
4040
4141-- Same as the fps function, but you can turn it on and off. Allows you
4242-- to do brief animations based on user input without major ineffeciencies.
4343-- The first time delta after a pause is always zero, no matter how long
4444-- the pause was. This way summing the deltas will actually give the amount
4545-- of time that the output signal has been running.
46−fpsWhen : Number -> Signal Bool -> Signal Time
46+fpsWhen : Number a -> Signal Bool -> Signal Time
4747
4848-- Takes a time interval t. The resulting signal is the current time,
4949-- updated every t.