on master help sign in
Remove the standard libraries, migrating them to a separate repo
commit9ca51a9246387de746c72da282095bd2de6cdb00 authorEvan Czaplicki <info@elm-lang.org> dateTue 14 Oct 2014, 17:25 (12 years ago) parentfded78c
64 files changed−8726
libraries/Array.elm−198 libraries/Basics.elm−419 libraries/Bitwise.elm−74 libraries/Char.elm−62 libraries/Color.elm−272 libraries/Date.elm−76 libraries/Debug.elm−88 libraries/Dict.elm−419 libraries/Either.elm−91 libraries/Graphics/Collage.elm−261 libraries/Graphics/Element.elm−312 libraries/Graphics/Input.elm−178 libraries/Graphics/Input/Field.elm−170 libraries/Http.elm−54 libraries/JavaScript/Experimental.elm−56 libraries/Json.elm−49 libraries/Keyboard.elm−82 libraries/List.elm−326 libraries/Maybe.elm−61 libraries/Mouse.elm−36 libraries/Native/Array.js−709 libraries/Native/Basics.js−111 libraries/Native/Bitwise.js−25 libraries/Native/Char.js−31 libraries/Native/Color.js−32 libraries/Native/Date.js−33 libraries/Native/Debug.js−60 libraries/Native/Error.js−30 libraries/Native/Function.js−101 libraries/Native/Graphics/Collage.js−23 libraries/Native/Graphics/Input.js−410 libraries/Native/JavaScript.js−68 libraries/Native/Json.js−85 libraries/Native/List.js−395 libraries/Native/Ports.js−83 libraries/Native/Regex.js−103 libraries/Native/Show.js−132 libraries/Native/Signal/Http.js−63 libraries/Native/Signal/Keyboard.js−154 libraries/Native/Signal/Mouse.js−47 libraries/Native/Signal/Random.js−39 libraries/Native/Signal/Signal.js−227 libraries/Native/Signal/Time.js−70 libraries/Native/Signal/Touch.js−152 libraries/Native/Signal/WebSocket.js−36 libraries/Native/Signal/Window.js−57 libraries/Native/String.js−252 libraries/Native/Text.js−167 libraries/Native/Trampoline.js−24 libraries/Native/Transform2D.js−99 libraries/Native/Utils.js−267 libraries/Random.elm−30 libraries/Regex.elm−126 libraries/Set.elm−102 libraries/Signal.elm−170 libraries/String.elm−340 libraries/Text.elm−221 libraries/Time.elm−99 libraries/Touch.elm−34 libraries/Trampoline.elm−49 libraries/Transform2D.elm−96 libraries/WebSocket.elm−21 libraries/Window.elm−27 libraries/elm_dependencies.json−42
libraries/Array.elmdeleted−198
@@ -1,198 +0,0 @@
1−module Array where
2−
3−{-| A library for fast immutable arrays. The elements in an array must have the
4−same type. The arrays are implemented in Relaxed Radix Balanced-Trees for fast
5−reads, updates, and appends.
6−
7−# Creating Arrays
8−@docs empty, repeat, initialize, fromList
9−
10−# Basics
11−@docs length, push, append
12−
13−# Get and Set
14−@docs get, getOrElse, getOrFail, set
15−
16−# Taking Arrays Apart
17−@docs slice, toList, toIndexedList
18−
19−# Mapping and Folding
20−@docs map, indexedMap, foldl, foldr
21−-}
22−
23−import Native.Array
24−import Basics (..)
25−import Maybe (..)
26−import List
27−
28−data Array a = Array
29−
30−{-| Initialize an array. `initialize n f` creates an array of length `n` with
31−the element at index `i` initialized to the result of `(f i)`.
32−
33− initialize 4 id == fromList [0,1,2,3]
34− initialize 4 (\n -> n*n) == fromList [0,1,4,9]
35− initialize 4 (always 0) == fromList [0,0,0,0]
36−-}
37−initialize : Int -> (Int -> a) -> Array a
38−initialize = Native.Array.initialize
39−
40−{-| Creates an array with a given length, filled with a default element.
41−
42− repeat 5 0 == fromList [0,0,0,0,0]
43− repeat 3 "cat" == fromList ["cat","cat","cat"]
44−
45−Notice that `repeat 3 x` is the same as `initialize 3 (always x)`.
46−-}
47−repeat : Int -> a -> Array a
48−repeat n e = initialize n (always e)
49−
50−{-| Create an array from a list. -}
51−fromList : [a] -> Array a
52−fromList = Native.Array.fromList
53−
54−{-| Create a list of elements from an array.
55−
56− toList (fromList [3,5,8]) == [3,5,8]
57−-}
58−toList : Array a -> [a]
59−toList = Native.Array.toList
60−
61−-- TODO: make this a native function.
62−{-| Create an indexed list from an array. Each element of the array will be
63−paired with its index.
64−
65− toIndexedList (fromList ["cat","dog"]) == [(0,"cat"), (1,"dog")]
66−-}
67−toIndexedList : Array a -> [(Int, a)]
68−toIndexedList array =
69− List.zip [ 0 .. Native.Array.length array - 1 ] (Native.Array.toList array)
70−
71−{-| Apply a function on every element in an array.
72−
73− map sqrt (fromList [1,4,9]) == fromList [1,2,3]
74−-}
75−map : (a -> b) -> Array a -> Array b
76−map = Native.Array.map
77−
78−{-| Apply a function on every element with its index as first argument.
79−
80− indexedMap (*) (fromList [5,5,5]) == fromList [0,5,10]
81−-}
82−indexedMap : (Int -> a -> b) -> Array a -> Array b
83−indexedMap = Native.Array.indexedMap
84−
85−{-| Reduce an array from the left. Read `foldl` as &ldquo;fold from the left&rdquo;.
86−
87− foldl (::) [] (fromList [1,2,3]) == [3,2,1]
88−-}
89−foldl : (a -> b -> b) -> b -> Array a -> b
90−foldl = Native.Array.foldl
91−
92−{-| Reduce an array from the right. Read `foldr` as &ldquo;fold from the right&rdquo;.
93−
94− foldr (+) 0 (repeat 3 5) == 15
95−-}
96−foldr : (a -> b -> b) -> b -> Array a -> b
97−foldr = Native.Array.foldr
98−
99−{-| Keep only elements that satisfy the predicate:
100−
101− filter isEven (fromList [1..6]) == (fromList [2,4,6])
102−-}
103−filter : (a -> Bool) -> Array a -> Array a
104−filter isOkay arr =
105− let update x xs = if isOkay x then Native.Array.push x xs else xs
106− in
107− Native.Array.foldl update Native.Array.empty arr
108−
109−{-| Return an empty array.
110−
111− length empty == 0
112−-}
113−empty : Array a
114−empty = Native.Array.empty
115−
116−{-| Push an element to the end of an array.
117−
118− push 3 (fromList [1,2]) == fromList [1,2,3]
119−-}
120−push : a -> Array a -> Array a
121−push = Native.Array.push
122−
123−{-| Get the element at a particular index.
124−
125− getOrFail 0 (A.fromList [0,1,2]) == 0
126−
127−Warning: this function will result in a runtime error if the index is not found,
128−so it is best to use `get` or `getOrElse` unless you are sure the index will be
129−found.
130−-}
131−getOrFail : Int -> Array a -> a
132−getOrFail = Native.Array.get
133−
134−{-| Return Just the element at the index or Nothing if the index is out of range.
135−
136− get 0 (fromList [0,1,2]) == Just 0
137− get 2 (fromList [0,1,2]) == Just 2
138− get 5 (fromList [0,1,2]) == Nothing
139− get -1 (fromList [0,1,2]) == Nothing
140−-}
141−get : Int -> Array a -> Maybe a
142−get i array =
143− if 0 <= i && i < Native.Array.length array
144− then Just (Native.Array.get i array)
145− else Nothing
146−
147−{-| Get the element at the index. Or if the index is out of range, a default
148−value is returned.
149−
150− getOrElse 0 2 (fromList [0,1,2]) == 2
151− getOrElse 0 5 (fromList [0,1,2]) == 0
152−-}
153−getOrElse : a -> Int -> Array a -> a
154−getOrElse default i array =
155− if 0 <= i && i < Native.Array.length array
156− then Native.Array.get i array
157− else default
158−
159−{-| Set the element at a particular index. Returns an updated array.
160−If the index is out of range, the array is unaltered.
161−
162− set 1 7 (fromList [1,2,3]) == fromList [1,7,3]
163−-}
164−set : Int -> a -> Array a -> Array a
165−set = Native.Array.set
166−
167−{-| Get a sub-section of an array: `(slice start end array)`. The `start` is a
168−zero-based index where we will start our slice. The `end` is a zero-based index
169−that indicates the end of the slice. The slice extracts up to but not including
170−`end`.
171−
172− slice 0 3 (fromList [0,1,2,3,4]) == fromList [0,1,2]
173− slice 1 4 (fromList [0,1,2,3,4]) == fromList [1,2,3]
174−
175−Both the `start` and `end` indexes can be negative, indicating an offset from
176−the end of the array.
177−
178− slice 1 -1 (fromList [0,1,2,3,4]) == fromList [1,2,3]
179− slice -2 5 (fromList [0,1,2,3,4]) == fromList [3,4]
180−
181−This makes it pretty easy to `pop` the last element off of an array: `slice 0 -1 array`
182−-}
183−slice : Int -> Int -> Array a -> Array a
184−slice = Native.Array.slice
185−
186−{-| Return the length of an array.
187−
188− length (fromList [1,2,3]) == 3
189−-}
190−length : Array a -> Int
191−length = Native.Array.length
192−
193−{-| Append two arrays to a new one.
194−
195− append (repeat 2 42) (repeat 3 81) == fromList [42,42,81,81,81]
196−-}
197−append : Array a -> Array a -> Array a
198−append = Native.Array.append
libraries/Basics.elmdeleted−419
@@ -1,419 +0,0 @@
1−
2−module Basics where
3−
4−{-| Tons of useful functions that get imported by default.
5−
6−The following libraries also get imported by default: List, Signal,
7−Text, Maybe, Time, Graphics.Element, Color, Graphics.Collage.
8−
9−# Equality
10−@docs (==), (/=)
11−
12−# Comparison
13−
14−These functions only work on `comparable` types. This includes numbers,
15−characters, strings, lists of comparable things, and tuples of comparable
16−things. Note that tuples with 7 or more elements are not comparable; why
17−are your tuples so big?
18−
19−@docs (<), (>), (<=), (>=), max, min, Order, compare
20−
21−# Booleans
22−@docs not, (&&), (||), xor, otherwise
23−
24−# Mathematics
25−@docs (+), (-), (*), (/), (^), (//), rem, (%), negate, abs, sqrt, clamp, logBase, e
26−
27−# Trigonometry
28−@docs pi, cos, sin, tan, acos, asin, atan, atan2
29−
30−# Number Conversions
31−@docs round, floor, ceiling, truncate, toFloat
32−
33−# Angle Conversions
34−All angle conversions result in &ldquo;standard Elm angles&rdquo;
35−which happen to be radians.
36−
37−@docs degrees, radians, turns
38−
39−# Polar Coordinates
40−@docs toPolar, fromPolar
41−
42−# Floating Point Checks
43−@docs isNaN, isInfinite
44−
45−# Tuples
46−@docs fst, snd
47−
48−# Higher-Order Helpers
49−@docs identity, always, (<|), (|>), (<<), (>>), flip, curry, uncurry
50−
51−-}
52−
53−import Native.Basics
54−
55−{-| Convert radians to standard Elm angles (radians). -}
56−radians : Float -> Float
57−radians t = t
58−
59−{-| Convert degrees to standard Elm angles (radians). -}
60−degrees : Float -> Float
61−degrees = Native.Basics.degrees
62−
63−{-| Convert turns to standard Elm angles (radians).
64−One turn is equal to 360&deg;.
65−-}
66−turns : Float -> Float
67−turns = Native.Basics.turns
68−
69−{-| Start with polar coordinates (r,&theta;)
70−and get out cartesian coordinates (x,y).
71−-}
72−fromPolar : (Float,Float) -> (Float,Float)
73−fromPolar = Native.Basics.fromPolar
74−
75−{-| Start with cartesian coordinates (x,y)
76−and get out polar coordinates (r,&theta;).
77−-}
78−toPolar : (Float,Float) -> (Float,Float)
79−toPolar = Native.Basics.toPolar
80−
81−(+) : number -> number -> number
82−(+) = Native.Basics.add
83−
84−(-) : number -> number -> number
85−(-) = Native.Basics.sub
86−
87−(*) : number -> number -> number
88−(*) = Native.Basics.mul
89−
90−{-| Floating point division. -}
91−(/) : Float -> Float -> Float
92−(/) = Native.Basics.floatDiv
93−
94−infixl 6 +
95−infixl 6 -
96−infixl 7 *
97−infixl 7 /
98−infixl 8 ^
99−
100−infixl 7 //
101−infixl 7 %
102−infixl 7 `rem`
103−
104−{-| Integer division, remainder is discarded. -}
105−(//) : Int -> Int -> Int
106−(//) = Native.Basics.div
107−
108−{-| Finds the remainder after dividing one number by another:
109−
110− 7 `rem` 2 == 1
111− -1 `rem` 4 == -1
112−-}
113−rem : Int -> Int -> Int
114−rem = Native.Basics.rem
115−
116−{-| Perform [modular arithmetic](http://en.wikipedia.org/wiki/Modular_arithmetic):
117−
118− 7 % 2 == 1
119− -1 % 4 == 3
120−-}
121−(%) : Int -> Int -> Int
122−(%) = Native.Basics.mod
123−
124−{-| Exponentiation: `3^2 == 9` -}
125−(^) : number -> number -> number
126−(^) = Native.Basics.exp
127−
128−cos : Float -> Float
129−cos = Native.Basics.cos
130−
131−sin : Float -> Float
132−sin = Native.Basics.sin
133−
134−tan : Float -> Float
135−tan = Native.Basics.tan
136−
137−acos : Float -> Float
138−acos = Native.Basics.acos
139−
140−asin : Float -> Float
141−asin = Native.Basics.asin
142−
143−{-| You probably do not want to use this. It takes `(y/x)` as the
144−argument, so there is no way to know whether the negative signs comes from
145−the `y` or `x`. Thus, the resulting angle is always between &pi;/2 and -&pi;/2
146−(in quadrants I and IV). You probably want to use `atan2` instead.
147−-}
148−atan : Float -> Float
149−atan = Native.Basics.atan
150−
151−{-| This helps you find the angle of a cartesian coordinate.
152−You will almost certainly want to use this instead of `atan`.
153−So `atan2 y x` computes *atan(y/x)* but also keeps track of which
154−quadrant the angle should really be in. The result will be between
155−&pi; and -&pi;, giving you the full range of angles.
156−-}
157−atan2 : Float -> Float -> Float
158−atan2 = Native.Basics.atan2
159−
160−{-| Take the square root of a number. -}
161−sqrt : Float -> Float
162−sqrt = Native.Basics.sqrt
163−
164−{-| Negate any number: `negate 42 == -42` -}
165−negate : number -> number
166−negate = Native.Basics.negate
167−
168−{-| Take the absolute value of a number. -}
169−abs : number -> number
170−abs = Native.Basics.abs
171−
172−{-| Calculate the logarithm of a number with a given base: `logBase 10 100 == 2` -}
173−logBase : Float -> Float -> Float
174−logBase = Native.Basics.logBase
175−
176−{-| Clamps a number within a given range. With the expression
177−`clamp 100 200 x` the results are as follows:
178−
179− 100 if x < 100
180− x if 100 <= x < 200
181− 200 if 200 <= x
182−-}
183−clamp : number -> number -> number -> number
184−clamp = Native.Basics.clamp
185−
186−{-| An approximation of pi. -}
187−pi : Float
188−pi = Native.Basics.pi
189−
190−{-| An approximation of e. -}
191−e : Float
192−e = Native.Basics.e
193−
194−(==) : a -> a -> Bool
195−(==) = Native.Basics.eq
196−
197−(/=) : a -> a -> Bool
198−(/=) = Native.Basics.neq
199−
200−(<) : comparable -> comparable -> Bool
201−(<) = Native.Basics.lt
202−
203−(>) : comparable -> comparable -> Bool
204−(>) = Native.Basics.gt
205−
206−(<=) : comparable -> comparable -> Bool
207−(<=) = Native.Basics.le
208−
209−(>=) : comparable -> comparable -> Bool
210−(>=) = Native.Basics.ge
211−
212−infix 4 ==
213−infix 4 /=
214−infix 4 <
215−infix 4 >
216−infix 4 <=
217−infix 4 >=
218−
219−{-| Compare any two comparable values. Comparable values include `String`, `Char`,
220−`Int`, `Float`, `Time`, or a list or tuple containing comparable values.
221−These are also the only values that work as `Dict` keys or `Set` members.
222−-}
223−compare : comparable -> comparable -> Order
224−compare = Native.Basics.compare
225−
226−{-| Represents the relative ordering of two things.
227−The relations are less than, equal to, and greater than.
228−-}
229−data Order = LT | EQ | GT
230−
231−{-| Given two comparables, returns the smaller one. -}
232−min : comparable -> comparable -> comparable
233−min = Native.Basics.min
234−
235−{-| Given two comparables, returns the larger one. -}
236−max : comparable -> comparable -> comparable
237−max = Native.Basics.max
238−
239−{-| The and operator. True if both inputs are True.
240−This operator short-circuits if the first argument is False.
241−-}
242−(&&) : Bool -> Bool -> Bool
243−(&&) = Native.Basics.and
244−
245−{-| The or operator. True if one or both inputs are True.
246−This operator short-circuits if the first argument is True.
247−-}
248−(||) : Bool -> Bool -> Bool
249−(||) = Native.Basics.or
250−
251−infixr 3 &&
252−infixr 2 ||
253−
254−{-| The exclusive-or operator. True if exactly one input is True. -}
255−xor : Bool -> Bool -> Bool
256−xor = Native.Basics.xor
257−
258−{-| Negate a boolean value: `(not True == False)` and `(not False == True)` -}
259−not : Bool -> Bool
260−not = Native.Basics.not
261−
262−{-| Equal to true. Useful as the last case of a multi-way-if. -}
263−otherwise : Bool
264−otherwise = True
265−
266−
267−-- Conversions
268−
269−{-| Round a number to the nearest integer. -}
270−round : Float -> Int
271−round = Native.Basics.round
272−
273−{-| Truncate a decimal number, rounding towards zero. -}
274−truncate : Float -> Int
275−truncate = Native.Basics.truncate
276−
277−{-| Floor function, rounding down. -}
278−floor : Float -> Int
279−floor = Native.Basics.floor
280−
281−{-| Ceiling function, rounding up. -}
282−ceiling : Float -> Int
283−ceiling = Native.Basics.ceiling
284−
285−{-| Convert an integer into a float. -}
286−toFloat : Int -> Float
287−toFloat = Native.Basics.toFloat
288−
289−{- | Determines whether a float is an undefined or unrepresentable number.
290−NaN stands for *not a number* and it is [a standardized part of floating point
291−numbers](http://en.wikipedia.org/wiki/NaN).
292−
293− isNaN (0/0) == True
294− isNaN (sqrt -1) == True
295− isNaN (1/0) == False -- infinity is a number
296− isNaN 1 == False
297−-}
298−isNaN : Float -> Bool
299−isNaN = Native.Basics.isNaN
300−
301−{- | Determines whether a float is positive or negative infinity.
302−
303− isInfinite (0/0) == False
304− isInfinite (sqrt -1) == False
305− isInfinite (1/0) == True
306− isInfinite 1 == False
307−
308−Notice that NaN is not infinite! For float `n` to be finite implies that
309−`not (isInfinite n || isNaN n)` evaluates to `True`.
310−-}
311−isInfinite : Float -> Bool
312−isInfinite = Native.Basics.isInfinite
313−
314−-- Function Helpers
315−
316−{-| Function composition, passing results along in the suggested direction. For
317−example, the following code checks if the square root of a number is odd:
318−
319− not << isEven << sqrt
320−
321−You can think of this operator as equivalent to the following:
322−
323− (g << f) == (\x -> g (f x))
324−
325−So our example expands out to something like this:
326−
327− \n -> not (isEven (sqrt n))
328−-}
329−(<<) : (b -> c) -> (a -> b) -> (a -> c)
330−(<<) g f x = g (f x)
331−
332−{-| Function composition, passing results along in the suggested direction. For
333−example, the following code checks if the square root of a number is odd:
334−
335− sqrt >> isEven >> not
336−
337−This direction of function composition seems less pleasant than `(<<)` which
338−reads nicely in expressions like: `filter (not << isRegistered) students`
339−-}
340−(>>) : (a -> b) -> (b -> c) -> (a -> c)
341−(>>) f g x = g (f x)
342−
343−{-| Forward function application `x |> f == f x`. This function is useful
344−for avoiding parenthesis and writing code in a more natural way.
345−Consider the following code to create a pentagon:
346−
347− scale 2 (move (10,10) (filled blue (ngon 5 30)))
348−
349−This can also be written as:
350−
351− ngon 5 30 |> filled blue
352− |> move (10,10)
353− |> scale 2
354−-}
355−(|>) : a -> (a -> b) -> b
356−x |> f = f x
357−
358−{-| Function application `f <| x == f x`. This function is useful for avoiding
359−parenthesis. Consider the following code to create a text element:
360−
361− text (monospace (toText "code"))
362−
363−This can also be written as:
364−
365− text . monospace <| toText "code"
366−-}
367−(<|) : (a -> b) -> a -> b
368−f <| x = f x
369−
370−infixr 9 <<
371−infixl 9 >>
372−infixr 0 <|
373−infixl 0 |>
374−
375−{-| Given a value, returns exactly the same value. This is called
376−[the identity function](http://en.wikipedia.org/wiki/Identity_function).
377−-}
378−identity : a -> a
379−identity x = x
380−
381−{-| Creates a [constant function](http://en.wikipedia.org/wiki/Constant_function),
382−a function that *always* returns the same value regardless of what input you give.
383−It is defined as:
384−
385− always a b = a
386−
387−It totally ignores the second argument, so `always 42` is a function that always
388−returns 42. When you are dealing with higher-order functions, this comes in
389−handy more often than you might expect. For example, creating a zeroed out list
390−of length ten would be:
391−
392− map (always 0) [0..9]
393−-}
394−always : a -> b -> a
395−always a _ = a
396−
397−{-| Given a 2-tuple, returns the first value. -}
398−fst : (a,b) -> a
399−fst (a,_) = a
400−
401−{-| Given a 2-tuple, returns the second value. -}
402−snd : (a,b) -> b
403−snd (_,b) = b
404−
405−{-| Flips the order of the first two arguments to a function. -}
406−flip : (a -> b -> c) -> (b -> a -> c)
407−flip f b a = f a b
408−
409−{-| Change how arguments are passed to a function.
410−This splits paired arguments into two separate arguments.
411−-}
412−curry : ((a,b) -> c) -> a -> b -> c
413−curry f a b = f (a,b)
414−
415−{-| Change how arguments are passed to a function.
416−This combines two arguments into a single pair.
417−-}
418−uncurry : (a -> b -> c) -> (a,b) -> c
419−uncurry f (a,b) = f a b
libraries/Bitwise.elmdeleted−74
@@ -1,74 +0,0 @@
1−module Bitwise where
2−
3−{-| Library for [bitwise operations](http://en.wikipedia.org/wiki/Bitwise_operation).
4−
5−# Basic Operations
6−
7−@docs and, or, xor, complement
8−
9−# Bit Shifts
10−
11−@docs shiftLeft, shiftRight, shiftRightLogical
12−-}
13−
14−import Native.Bitwise
15−
16−{-| Bitwise AND
17−-}
18−and : Int -> Int -> Int
19−and = Native.Bitwise.and
20−
21−{-| Bitwise OR
22−-}
23−or : Int -> Int -> Int
24−or = Native.Bitwise.or
25−
26−{-| Bitwise XOR
27−-}
28−xor : Int -> Int -> Int
29−xor = Native.Bitwise.xor
30−
31−{-| Flip each bit individually, often called bitwise NOT
32−-}
33−complement : Int -> Int
34−complement = Native.Bitwise.complement
35−
36−{-| Shift bits to the left by a given offset, filling new bits with zeros.
37−This can be used to multiply numbers by powers of two.
38−
39− 8 `shiftLeft` 1 == 16
40− 8 `shiftLeft` 2 == 32
41−-}
42−shiftLeft : Int -> Int -> Int
43−shiftLeft = Native.Bitwise.shiftLeft
44−
45−{-| Shift bits to the right by a given offset, filling new bits with
46−whatever is the topmost bit. This can be used to divide numbers by powers of two.
47−
48− 32 `shiftRight` 1 == 16
49− 32 `shiftRight` 2 == 8
50− -32 `shiftRight` 1 == -16
51−
52−This is called an [arithmatic right
53−shift](http://en.wikipedia.org/wiki/Bitwise_operation#Arithmetic_shift),
54−often written (>>), and sometimes called a sign-propagating
55−right shift because it fills empty spots with copies of the highest bit.
56−-}
57−shiftRight : Int -> Int -> Int
58−shiftRight = Native.Bitwise.shiftRightArithmatic
59−
60−{-| Shift bits to the right by a given offset, filling new bits with
61−zeros.
62−
63− 32 `shiftRightLogical` 1 == 16
64− 32 `shiftRightLogical` 2 == 8
65− -32 `shiftRightLogical` 1 == 2147483632
66−
67−This is called an [logical right
68−shift](http://en.wikipedia.org/wiki/Bitwise_operation#Logical_shift), often written (>>>),
69−and sometimes called a zero-fill right shift because it fills empty spots
70−with zeros.
71−-}
72−shiftRightLogical : Int -> Int -> Int
73−shiftRightLogical = Native.Bitwise.shiftRightLogical
74−
libraries/Char.elmdeleted−62
@@ -1,62 +0,0 @@
1−
2−module Char where
3−
4−{-| Functions for working with characters. Character literals are enclosed in
5−`'a'` pair of single quotes.
6−
7−# Classification
8−@docs isUpper, isLower, isDigit, isOctDigit, isHexDigit
9−
10−# Conversion
11−@docs toUpper, toLower, toLocaleUpper, toLocaleLower, toCode, fromCode
12−
13−-}
14−
15−import Native.Char
16−
17−{-| True for upper case letters. -}
18−isUpper : Char -> Bool
19−isUpper = Native.Char.isUpper
20−
21−{-| True for lower case letters. -}
22−isLower : Char -> Bool
23−isLower = Native.Char.isLower
24−
25−{-| True for ASCII digits `[0-9]`. -}
26−isDigit : Char -> Bool
27−isDigit = Native.Char.isDigit
28−
29−{-| True for ASCII octal digits `[0-7]`. -}
30−isOctDigit : Char -> Bool
31−isOctDigit = Native.Char.isOctDigit
32−
33−{-| True for ASCII hexadecimal digits `[0-9a-fA-F]`. -}
34−isHexDigit : Char -> Bool
35−isHexDigit = Native.Char.isHexDigit
36−
37−{-| Convert to upper case. -}
38−toUpper : Char -> Char
39−toUpper = Native.Char.toUpper
40−
41−{-| Convert to lower case. -}
42−toLower : Char -> Char
43−toLower = Native.Char.toLower
44−
45−{-| Convert to upper case, according to any locale-specific case mappings. -}
46−toLocaleUpper : Char -> Char
47−toLocaleUpper = Native.Char.toLocaleUpper
48−
49−{-| Convert to lower case, according to any locale-specific case mappings. -}
50−toLocaleLower : Char -> Char
51−toLocaleLower = Native.Char.toLocaleLower
52−
53−type KeyCode = Int
54−
55−{-| Convert to unicode. Used with the `Keyboard` library, which expects the
56−input to be uppercase. -}
57−toCode : Char -> KeyCode
58−toCode = Native.Char.toCode
59−
60−{-| Convert from unicode. -}
61−fromCode : KeyCode -> Char
62−fromCode = Native.Char.fromCode
libraries/Color.elmdeleted−272
@@ -1,272 +0,0 @@
1−module Color where
2−
3−{-| Library for working with colors. Includes
4−[RGB](https://en.wikipedia.org/wiki/RGB_color_model) and
5−[HSL](http://en.wikipedia.org/wiki/HSL_and_HSV) creation, gradients, and
6−built-in names.
7−
8−# Creation
9−@docs rgb, rgba, hsl, hsla, greyscale, grayscale, complement
10−
11−# Gradients
12−@docs linear, radial
13−
14−# Extracting Colors
15−@docs toRgb, toHsl
16−
17−# Built-in Colors
18−These colors come from the [Tango
19−palette](http://tango.freedesktop.org/Tango_Icon_Theme_Guidelines)
20−which provides aesthetically reasonable defaults for colors. Each color also
21−comes with a light and dark version.
22−
23−### Standard
24−@docs red, orange, yellow, green, blue, purple, brown
25−
26−### Light
27−@docs lightRed, lightOrange, lightYellow, lightGreen, lightBlue, lightPurple, lightBrown
28−
29−### Dark
30−@docs darkRed, darkOrange, darkYellow, darkGreen, darkBlue, darkPurple, darkBrown
31−
32−### Eight Shades of Grey
33−These colors are a compatible series of shades of grey, fitting nicely
34−with the Tango palette.
35−@docs white, lightGrey, grey, darkGrey, lightCharcoal, charcoal, darkCharcoal, black
36−
37−These are identical to the *grey* versions. It seems the spelling is regional, but
38−that has never helped me remember which one I should be writing.
39−@docs lightGray, gray, darkGray
40−
41−-}
42−
43−import Basics (..)
44−
45−data Color
46− = RGBA Int Int Int Float
47− | HSLA Float Float Float Float
48−
49−{-| Create RGB colors with an alpha component for transparency.
50−The alpha component is specified with numbers between 0 and 1. -}
51−rgba : Int -> Int -> Int -> Float -> Color
52−rgba = RGBA
53−
54−{-| Create RGB colors from numbers between 0 and 255 inclusive. -}
55−rgb : Int -> Int -> Int -> Color
56−rgb r g b = RGBA r g b 1
57−
58−{-| Create [HSL colors](http://en.wikipedia.org/wiki/HSL_and_HSV)
59−with an alpha component for transparency.
60−-}
61−hsla : Float -> Float -> Float -> Float -> Color
62−hsla hue saturation lightness alpha =
63− HSLA (hue - turns (toFloat (floor (hue / (2*pi))))) saturation lightness alpha
64−
65−{-| Create [HSL colors](http://en.wikipedia.org/wiki/HSL_and_HSV). This gives
66−you access to colors more like a color wheel, where all hues are aranged in a
67−circle that you specify with standard Elm angles (radians).
68−
69− red = hsl (degrees 0) 1 0.5
70− green = hsl (degrees 120) 1 0.5
71− blue = hsl (degrees 240) 1 0.5
72−
73− pastelRed = hsl (degrees 0) 0.7 0.7
74−
75−To cycle through all colors, just cycle through degrees. The saturation level
76−is how vibrant the color is, like a dial between grey and bright colors. The
77−lightness level is a dial between white and black.
78−-}
79−hsl : Float -> Float -> Float -> Color
80−hsl hue saturation lightness =
81− hsla hue saturation lightness 1
82−
83−{-| Produce a gray based on the input. 0 is white, 1 is black. -}
84−grayscale : Float -> Color
85−grayscale p = HSLA 0 0 (1-p) 1
86−
87−greyscale : Float -> Color
88−greyscale p = HSLA 0 0 (1-p) 1
89−
90−{-| Produce a &ldquo;complementary color&rdquo;. The two colors will
91−accent each other. This is the same as rotating the hue by 180&deg;.
92−-}
93−complement : Color -> Color
94−complement color =
95− case color of
96− HSLA h s l a -> hsla (h + degrees 180) s l a
97− RGBA r g b a -> let (h,s,l) = rgbToHsl r g b
98− in hsla (h + degrees 180) s l a
99−
100−{-| Extract the components of a color in the HSL format.
101−-}
102−toHsl : Color -> { hue:Float, saturation:Float, lightness:Float, alpha:Float }
103−toHsl color =
104− case color of
105− HSLA h s l a -> { hue=h, saturation=s, lightness=l, alpha=a }
106− RGBA r g b a ->
107− let (h,s,l) = rgbToHsl r g b
108− in { hue=h, saturation=s, lightness=l, alpha=a }
109−
110−{-| Extract the components of a color in the RGB format.
111−-}
112−toRgb : Color -> { red:Int, green:Int, blue:Int, alpha:Float }
113−toRgb color =
114− case color of
115− RGBA r g b a -> { red=r, green=g, blue=b, alpha=a }
116− HSLA h s l a ->
117− let (r,g,b) = hslToRgb h s l
118− in { red = round (255 * r)
119− , green = round (255 * g)
120− , blue = round (255 * b)
121− , alpha = a
122− }
123−
124−fmod : Float -> Int -> Float
125−fmod f n =
126− let integer = floor f
127− in toFloat (integer % n) + f - toFloat integer
128−
129−rgbToHsl : Int -> Int -> Int -> (Float,Float,Float)
130−rgbToHsl red green blue =
131− let r = toFloat red / 255
132− g = toFloat green / 255
133− b = toFloat blue / 255
134−
135− cMax = max (max r g) b
136− cMin = min (min r g) b
137−
138− c = cMax - cMin
139−
140− hue = degrees 60 * if | cMax == r -> ((g - b) / c) `fmod` 6
141− | cMax == g -> ((b - r) / c) + 2
142− | cMax == b -> ((r - g) / c) + 4
143−
144− lightness = (cMax + cMin) / 2
145−
146− saturation =
147− if lightness == 0
148− then 0
149− else c / (1 - abs (2 * lightness - 1))
150− in
151− (hue, saturation, lightness)
152−
153−hslToRgb : Float -> Float -> Float -> (Float,Float,Float)
154−hslToRgb hue saturation lightness =
155− let chroma = (1 - abs (2 * lightness - 1)) * saturation
156− hue' = hue / degrees 60
157−
158− x = chroma * (1 - abs (fmod hue' 2 - 1))
159−
160− (r,g,b) = if | hue' < 0 -> (0, 0, 0)
161− | hue' < 1 -> (chroma, x, 0)
162− | hue' < 2 -> (x, chroma, 0)
163− | hue' < 3 -> (0, chroma, x)
164− | hue' < 4 -> (0, x, chroma)
165− | hue' < 5 -> (x, 0, chroma)
166− | hue' < 6 -> (chroma, 0, x)
167− | otherwise -> (0, 0, 0)
168−
169− m = lightness - chroma / 2
170− in
171− (r + m, g + m, b + m)
172−
173−--toV3 : Color -> V3
174−
175−--toV4 : Color -> V4
176−
177−data Gradient
178− = Linear (Float,Float) (Float,Float) [(Float,Color)]
179− | Radial (Float,Float) Float (Float,Float) Float [(Float,Color)]
180−
181−{-| Create a linear gradient. Takes a start and end point and then a series of
182−&ldquo;color stops&rdquo; that indicate how to interpolate between the start and
183−end points. See [this example](http://elm-lang.org/edit/examples/Elements/LinearGradient.elm) for a
184−more visual explanation. -}
185−linear : (number, number) -> (number, number) -> [(Float,Color)] -> Gradient
186−linear = Linear
187−
188−{-| Create a radial gradient. First takes a start point and inner radius. Then
189−takes an end point and outer radius. It then takes a series of &ldquo;color
190−stops&rdquo; that indicate how to interpolate between the inner and outer
191−circles. See [this example](http://elm-lang.org/edit/examples/Elements/RadialGradient.elm) for a
192−more visual explanation. -}
193−radial : (number,number) -> number -> (number,number) -> number -> [(Float,Color)] -> Gradient
194−radial = Radial
195−
196−
197−-- BUILT-IN COLORS
198−
199−lightRed : Color
200−lightRed = RGBA 239 41 41 1
201−red : Color
202−red = RGBA 204 0 0 1
203−darkRed : Color
204−darkRed = RGBA 164 0 0 1
205−
206−lightOrange : Color
207−lightOrange = RGBA 252 175 62 1
208−orange : Color
209−orange = RGBA 245 121 0 1
210−darkOrange : Color
211−darkOrange = RGBA 206 92 0 1
212−
213−lightYellow : Color
214−lightYellow = RGBA 255 233 79 1
215−yellow : Color
216−yellow = RGBA 237 212 0 1
217−darkYellow : Color
218−darkYellow = RGBA 196 160 0 1
219−
220−lightGreen : Color
221−lightGreen = RGBA 138 226 52 1
222−green : Color
223−green = RGBA 115 210 22 1
224−darkGreen : Color
225−darkGreen = RGBA 78 154 6 1
226−
227−lightBlue : Color
228−lightBlue = RGBA 114 159 207 1
229−blue : Color
230−blue = RGBA 52 101 164 1
231−darkBlue : Color
232−darkBlue = RGBA 32 74 135 1
233−
234−lightPurple : Color
235−lightPurple = RGBA 173 127 168 1
236−purple : Color
237−purple = RGBA 117 80 123 1
238−darkPurple : Color
239−darkPurple = RGBA 92 53 102 1
240−
241−lightBrown : Color
242−lightBrown = RGBA 233 185 110 1
243−brown : Color
244−brown = RGBA 193 125 17 1
245−darkBrown : Color
246−darkBrown = RGBA 143 89 2 1
247−
248−black : Color
249−black = RGBA 0 0 0 1
250−white : Color
251−white = RGBA 255 255 255 1
252−
253−lightGrey : Color
254−lightGrey = RGBA 238 238 236 1
255−grey : Color
256−grey = RGBA 211 215 207 1
257−darkGrey : Color
258−darkGrey = RGBA 186 189 182 1
259−
260−lightGray : Color
261−lightGray = RGBA 238 238 236 1
262−gray : Color
263−gray = RGBA 211 215 207 1
264−darkGray : Color
265−darkGray = RGBA 186 189 182 1
266−
267−lightCharcoal : Color
268−lightCharcoal = RGBA 136 138 133 1
269−charcoal : Color
270−charcoal = RGBA 85 87 83 1
271−darkCharcoal : Color
272−darkCharcoal = RGBA 46 52 54 1
libraries/Date.elmdeleted−76
@@ -1,76 +0,0 @@
1−
2−module Date where
3−
4−{-| Library for working with dates. Email the mailing list if you encounter
5−issues with internationalization or locale formatting.
6−
7−# Conversions
8−@docs read, toTime, fromTime
9−
10−# Extractions
11−@docs year, month, Month, day, dayOfWeek, Day, hour, minute, second
12−
13−-}
14−
15−import Native.Date
16−import Time (Time)
17−import Maybe (Maybe)
18−
19−data Date = Date
20−
21−{-| Represents the days of the week. -}
22−data Day = Mon | Tue | Wed | Thu | Fri | Sat | Sun
23−
24−{-| Represents the month of the year. -}
25−data Month = Jan | Feb | Mar | Apr
26− | May | Jun | Jul | Aug
27− | Sep | Oct | Nov | Dec
28−
29−{-| Attempt to read a date from a string. -}
30−read : String -> Maybe Date
31−read = Native.Date.read
32−
33−{-| Convert a date into a time since midnight (UTC) of 1 January 1990 (i.e.
34−[UNIX time](http://en.wikipedia.org/wiki/Unix_time)). Given the date 23 June
35−1990 at 11:45AM this returns the corresponding time. -}
36−toTime : Date -> Time
37−toTime = Native.Date.toTime
38−
39−{-| Take a UNIX time and convert it to a `Date` -}
40−fromTime : Time -> Date
41−fromTime = Native.Date.fromTime
42−
43−{-| Extract the year of a given date. Given the date 23 June 1990 at 11:45AM
44−this returns the integer `1990`. -}
45−year : Date -> Int
46−year = Native.Date.year
47−
48−{-| Extract the month of a given date. Given the date 23 June 1990 at 11:45AM
49−this returns the Month `Jun` as defined below. -}
50−month : Date -> Month
51−month = Native.Date.month
52−
53−{-| Extract the day of a given date. Given the date 23 June 1990 at 11:45AM
54−this returns the integer `23`. -}
55−day : Date -> Int
56−day = Native.Date.day
57−
58−{-| Extract the day of the week for a given date. Given the date 23 June
59−1990 at 11:45AM this returns the Day `Thu` as defined below. -}
60−dayOfWeek : Date -> Day
61−dayOfWeek = Native.Date.dayOfWeek
62−
63−{-| Extract the hour of a given date. Given the date 23 June 1990 at 11:45AM
64−this returns the integer `11`. -}
65−hour : Date -> Int
66−hour = Native.Date.hour
67−
68−{-| Extract the minute of a given date. Given the date 23 June 1990 at 11:45AM
69−this returns the integer `45`. -}
70−minute : Date -> Int
71−minute = Native.Date.minute
72−
73−{-| Extract the second of a given date. Given the date 23 June 1990 at 11:45AM
74−this returns the integer `0`. -}
75−second : Date -> Int
76−second = Native.Date.second
libraries/Debug.elmdeleted−88
@@ -1,88 +0,0 @@
1−module Debug where
2−{-| This library is for investigating bugs or performance problems. It should
3−*not* be used in production code.
4−
5−# Console Debugging
6−@docs log, crash
7−
8−# Time-Travel Debugging
9−@docs watch, watchSummary, trace
10−-}
11−
12−import Graphics.Collage (Form)
13−import Native.Debug
14−import Native.Error
15−
16−{-| Log a tagged value on the developer console, and then return the value.
17−
18− 1 + log "number" 1 -- equals 2, logs "number: 1"
19− length (log "start" []) -- equals 0, logs "start: []"
20−
21−Notice that `log` is not a pure function! It should *only* be used for
22−investigating bugs or performance problems.
23−-}
24−log : String -> a -> a
25−log = Native.Debug.log
26−
27−{-| Crash the program with an error message. This is an uncatchable error,
28−intended for code that is soon-to-be-implemented. For example, if you are
29−working with a large ADT and have partially completed a case expression, it may
30−make sense to do this:
31−
32− data Entity = Ship | Fish | Captain | Seagull
33−
34− drawEntity entity =
35− case entity of
36− Ship -> ...
37− Fish -> ...
38− _ -> Debug.crash ("drawEntity not implemented for " ++ show entity ++ " yet!")
39−
40−Note that incomplete pattern matches are *very* bad practice! They are one of
41−the very few ways to crash an Elm program, and they are completely avoidable.
42−Production code should not have incomplete pattern matches!
43−
44−**Use this if** you want to do some testing while you are partway through
45−writing a function.
46−
47−**Do not use this if** you want to do some typical try-catch exception handling.
48−Use the `Maybe` or `Either` libraries instead.
49−-}
50−crash : String -> a
51−crash = Native.Error.raise
52−
53−{-| Watch a particular value in the debugger. Say we want to know the value of
54−a variable called `velocity` because it may not be updated correctly. Adding
55−`Debug.watch` allows us to name the value and show it with the debugger.
56−
57− Debug.watch "velocity" velocity == velocity
58−
59−Notice that the result of evaluating this expression is exactly the same as
60−not having the expression at all. That means it's easy to add to any value.
61−-}
62−watch : String -> a -> a
63−watch = Native.Debug.watch
64−
65−{-| Watch a summary of a particular value in the debugger. This function is
66−pretty much the same as `watch` but it lets you specify a way to summarize
67−the value you are interested in. For example, maybe you only want to see part
68−of a record:
69−
70− Debug.watchSummary "velocity" .velocity object
71−
72−This is the same as just writing `object`, but it creates a watch that *only*
73−looks at the value of `object.velocity`. You can also show summary statistics
74−like length of a list:
75−
76− Debug.watchSummary "Number of clicks" length clicks
77−
78−Again, this evaluates to `clicks` but we get to see how long that list is in
79−the debugger.
80−-}
81−watchSummary : String -> (a -> b) -> a -> a
82−watchSummary = Native.Debug.watchSummary
83−
84−{-| Trace all past positions of a `Form` in the debugger. Add this to a `Form`
85−and you will see a line tracing its entire history.
86−-}
87−trace : String -> Form -> Form
88−trace = Native.Debug.tracePath
libraries/Dict.elmdeleted−419
@@ -1,419 +0,0 @@
1−module Dict
2− ( Dict
3− , empty, singleton, insert, update
4− , get, getOrElse, getOrFail
5− , remove, member
6− , filter
7− , partition
8− , foldl, foldr, map
9− , union, intersect, diff
10− , keys, values
11− , toList, fromList
12− ) where
13−
14−{-| A dictionary mapping unique keys to values. The keys can be any comparable
15−type. This includes `Int`, `Float`, `Time`, `Char`, `String`, and tuples or
16−lists of comparable types.
17−
18−Insert, remove, and query operations all take *O(log n)* time.
19−
20−# Build
21−@docs empty, singleton, insert, update, remove
22−
23−# Query
24−@docs member, get, getOrElse, getOrFail
25−
26−# Combine
27−@docs union, intersect, diff
28−
29−# Lists
30−@docs keys, values, toList, fromList
31−
32−# Transform
33−@docs map, foldl, foldr, filter, partition
34−
35−-}
36−
37−
38−import Basics (..)
39−import Maybe (..)
40−import Native.Error
41−import List
42−import List ((::))
43−import Native.Utils
44−
45−type Fakeout = (Int, Int)
46−
47−type Another = (Int, Int)
48−
49−-- BBlack and NBlack should only be used during the deletion
50−-- algorithm. Any other occurrence is a bug and should fail an assert.
51−data NColor
52− = Red
53− | Black
54− | BBlack -- Double Black, counts as 2 blacks for the invariant
55− | NBlack -- Negative Black, counts as -1 blacks for the invariant
56−
57−
58−showNColor : NColor -> String
59−showNColor c =
60− case c of
61− Red -> "Red"
62− Black -> "Black"
63− BBlack -> "BBlack"
64− NBlack -> "NBlack"
65−
66−data LeafColor
67− = LBlack
68− | LBBlack -- Double Black, counts as 2
69−
70−showLColor : LeafColor -> String
71−showLColor c = case c of
72− LBlack -> "LBlack"
73− LBBlack -> "LBBlack"
74−
75−data Dict k v
76− = RBNode NColor k v (Dict k v) (Dict k v)
77− | RBEmpty LeafColor
78−
79−{-| Create an empty dictionary. -}
80−empty : Dict comparable v
81−empty = RBEmpty LBlack
82−
83−min : Dict k v -> (k,v)
84−min t =
85− case t of
86− RBNode _ k v (RBEmpty LBlack) _ -> (k,v)
87− RBNode _ _ _ l _ -> min l
88− RBEmpty LBlack -> Native.Error.raise "(min Empty) is not defined"
89−
90−max : Dict k v -> (k, v)
91−max t =
92− case t of
93− RBNode _ k v _ (RBEmpty _) -> (k,v)
94− RBNode _ _ _ _ r -> max r
95− RBEmpty _ -> Native.Error.raise "(max Empty) is not defined"
96−
97−{-| Get the value associated with a key. If the key is not found, return
98−`Nothing`. This is useful when you are not sure if a key will be in the
99−dictionary.
100−
101− animals = fromList [ ("Tom", Cat), ("Jerry", Mouse) ]
102−
103− get "Tom" animals == Just Cat
104− get "Mouse" animals == Just Mouse
105− get "Spike" animals == Nothing
106−
107−The `getOrElse` and `getOrFail` are built-in ways to handle common ways of
108−using the resulting `Maybe`.
109−-}
110−get : comparable -> Dict comparable v -> Maybe v
111−get k t =
112− case t of
113− RBEmpty LBlack -> Nothing
114− RBNode _ k' v l r ->
115− case Native.Utils.compare k k' of
116− LT -> get k l
117− EQ -> Just v
118− GT -> get k r
119−
120−{-| Get the value associated with a key. If the key is not found,
121−return a default value.
122−
123− animals = fromList [ ("Tom", Cat), ("Jerry", Mouse) ]
124−
125− getOrElse Dog "Tom" animals == Cat
126− getOrElse Dog "Mouse" animals == Mouse
127− getOrElse Dog "Spike" animals == Dog
128−-}
129−getOrElse : v -> comparable -> Dict comparable v -> v
130−getOrElse base k t =
131− case t of
132− RBEmpty LBlack -> base
133− RBNode _ k' v l r ->
134− case Native.Utils.compare k k' of
135− LT -> getOrElse base k l
136− EQ -> v
137− GT -> getOrElse base k r
138−
139−{-| Get the value associated with a key.
140−
141− animals = fromList [ ("Tom", Cat), ("Jerry", Mouse) ]
142−
143− getOrFail "Tom" animals == Cat
144− getOrFail "Mouse" animals == Mouse
145− getOrFail "Spike" animals == -- Runtime Error!
146−
147−Warning: this function will result in a runtime error if the key is not found,
148−so it is best to use `get` or `getOrElse` unless you are sure the key will be
149−found.
150−-}
151−getOrFail : comparable -> Dict comparable v -> v
152−getOrFail k t =
153− case t of
154− RBEmpty LBlack -> Native.Error.raise "key not found when using 'getOrFail'"
155− RBNode _ k' v l r ->
156− case Native.Utils.compare k k' of
157− LT -> getOrFail k l
158− EQ -> v
159− GT -> getOrFail k r
160−
161−{-| Determine if a key is in a dictionary. -}
162−member : comparable -> Dict comparable v -> Bool
163−-- Does t contain k?
164−member k t = isJust <| get k t
165−
166−ensureBlackRoot : Dict k v -> Dict k v
167−ensureBlackRoot t =
168− case t of
169− RBNode Red k v l r -> RBNode Black k v l r
170− RBNode Black _ _ _ _ -> t
171− RBEmpty LBlack -> t
172−
173−{-| Insert a key-value pair into a dictionary. Replaces value when there is
174−a collision. -}
175−insert : comparable -> v -> Dict comparable v -> Dict comparable v
176−insert k v t = let u _ = Just v in
177− update k u t
178−
179−{-| Remove a key-value pair from a dictionary. If the key is not found,
180−no changes are made. -}
181−remove : comparable -> Dict comparable v -> Dict comparable v
182−remove k t = let u _ = Nothing in
183− update k u t
184−
185−data Flag = Insert | Remove | Same
186−showFlag : Flag -> String
187−showFlag f = case f of
188− Insert -> "Insert"
189− Remove -> "Remove"
190− Same -> "Same"
191−
192−{-| Update the value of a dictionary for a specific key with a given function. -}
193−update : comparable -> (Maybe v -> Maybe v) -> Dict comparable v -> Dict comparable v
194−update k u t =
195− let up t = case t of
196− RBEmpty LBlack -> case u Nothing of
197− Nothing -> (Same, empty)
198− Just v -> (Insert, RBNode Red k v empty empty)
199− RBNode c k' v l r -> case Native.Utils.compare k k' of
200− EQ -> case u (Just v) of
201− Nothing -> (Remove, rem c l r)
202− Just v' -> (Same, RBNode c k' v' l r)
203− LT -> let (fl, l') = up l in
204− case fl of
205− Same -> (Same, RBNode c k' v l' r)
206− Insert -> (Insert, balance c k' v l' r)
207− Remove -> (Remove, bubble c k' v l' r)
208− GT -> let (fl, r') = up r in
209− case fl of
210− Same -> (Same, RBNode c k' v l r')
211− Insert -> (Insert, balance c k' v l r')
212− Remove -> (Remove, bubble c k' v l r')
213− (fl, t') = up t
214− in case fl of
215− Same -> t'
216− Insert -> ensureBlackRoot t'
217− Remove -> blacken t'
218−
219−{-| Create a dictionary with one key-value pair. -}
220−singleton : comparable -> v -> Dict comparable v
221−singleton k v = insert k v (RBEmpty LBlack)
222−
223−isBBlack : Dict k v -> Bool
224−isBBlack t = case t of
225− RBNode BBlack _ _ _ _ -> True
226− RBEmpty LBBlack -> True
227− _ -> False
228−
229−moreBlack : NColor -> NColor
230−moreBlack c = case c of
231− Black -> BBlack
232− Red -> Black
233− NBlack -> Red
234− BBlack -> Native.Error.raise "Can't make a double black node more black!"
235−
236−lessBlack : NColor -> NColor
237−lessBlack c = case c of
238− BBlack -> Black
239− Black -> Red
240− Red -> NBlack
241− NBlack -> Native.Error.raise "Can't make a negative black node less black!"
242−
243−lessBlackTree : Dict k v -> Dict k v
244−lessBlackTree t = case t of
245− RBNode c k v l r -> RBNode (lessBlack c) k v l r
246− RBEmpty LBBlack -> RBEmpty LBlack
247−
248−reportRemBug : String -> NColor -> String -> String -> a
249−reportRemBug msg c lgot rgot =
250− Native.Error.raise <| List.concat [
251− "Internal red-black tree invariant violated, expected ",
252− msg,
253− "and got",
254− showNColor c,
255− " ",
256− lgot,
257− " ",
258− rgot,
259− "\nPlease report this bug to https://github.com/elm-lang/Elm/issues"
260− ]
261−
262−-- Remove the top node from the tree, may leave behind BBlacks
263−rem : NColor -> Dict k v -> Dict k v -> Dict k v
264−rem c l r = case (l, r) of
265− ((RBEmpty _), (RBEmpty _)) -> case c of
266− Red -> RBEmpty LBlack
267− Black -> RBEmpty LBBlack
268− ((RBEmpty cl), (RBNode cr k' v' l' r')) ->
269− case (c, cl, cr) of
270− (Black, LBlack, Red) -> RBNode Black k' v' l' r'
271− _ -> reportRemBug "Black, LBlack, Red" c (showLColor cl) (showNColor cr)
272− ((RBNode cl k' v' l' r'), (RBEmpty cr)) ->
273− case (c, cl, cr) of
274− (Black, Red, LBlack) -> RBNode Black k' v' l' r'
275− _ -> reportRemBug "Black, Red, LBlack" c (showNColor cl) (showLColor cr)
276− -- l and r are both RBNodes
277− ((RBNode cl kl vl ll rl), (RBNode cr kr vr lr rr)) ->
278− let l = RBNode cl kl vl ll rl
279− r = RBNode cr kr vr lr rr
280− (k, v) = max l
281− l' = remove_max cl kl vl ll rl
282− in bubble c k v l' r
283−
284−-- Kills a BBlack or moves it upward, may leave behind NBlack
285−bubble : NColor -> k -> v -> Dict k v -> Dict k v -> Dict k v
286−bubble c k v l r = if isBBlack l || isBBlack r
287− then balance (moreBlack c) k v (lessBlackTree l) (lessBlackTree r)
288− else RBNode c k v l r
289−
290−-- Removes rightmost node, may leave root as BBlack
291−remove_max : NColor -> k -> v -> Dict k v -> Dict k v -> Dict k v
292−remove_max c k v l r = case r of
293− RBEmpty _ -> rem c l r
294− RBNode cr kr vr lr rr
295− -> bubble c k v l (remove_max cr kr vr lr rr)
296−
297−-- generalized tree balancing act
298−balance : NColor -> k -> v -> Dict k v -> Dict k v -> Dict k v
299−balance c k v l r =
300−
301− balance_node (RBNode c k v l r)
302−
303−blackish : Dict k v -> Bool
304−blackish t = case t of
305− RBNode c _ _ _ _ -> c == Black || c == BBlack
306− RBEmpty _ -> True
307−
308−balance_node : Dict k v -> Dict k v
309−balance_node t =
310− let assemble col xk xv yk yv zk zv a b c d =
311− RBNode (lessBlack col) yk yv (RBNode Black xk xv a b) (RBNode Black zk zv c d)
312− in
313− if blackish t
314− then case t of
315− RBNode col zk zv (RBNode Red yk yv (RBNode Red xk xv a b) c) d ->
316− assemble col xk xv yk yv zk zv a b c d
317− RBNode col zk zv (RBNode Red xk xv a (RBNode Red yk yv b c)) d ->
318− assemble col xk xv yk yv zk zv a b c d
319− RBNode col xk xv a (RBNode Red zk zv (RBNode Red yk yv b c) d) ->
320− assemble col xk xv yk yv zk zv a b c d
321− RBNode col xk xv a (RBNode Red yk yv b (RBNode Red zk zv c d)) ->
322− assemble col xk xv yk yv zk zv a b c d
323−
324− RBNode BBlack xk xv a (RBNode NBlack zk zv (RBNode Black yk yv b c) d) ->
325− case d of
326− (RBNode Black _ _ _ _) ->
327− RBNode Black yk yv (RBNode Black xk xv a b) (balance Black zk zv c (redden d))
328− _ -> t
329−
330− RBNode BBlack zk zv (RBNode NBlack xk xv a (RBNode Black yk yv b c)) d ->
331− case a of
332− (RBNode Black _ _ _ _) ->
333− RBNode Black yk yv (balance Black xk xv (redden a) b) (RBNode Black zk zv c d)
334− _ -> t
335− _ -> t
336− else t
337−
338−-- make the top node black
339−blacken : Dict k v -> Dict k v
340−blacken t = case t of
341− RBEmpty _ -> RBEmpty LBlack
342− RBNode _ k v l r -> RBNode Black k v l r
343−
344−-- make the top node red
345−redden : Dict k v -> Dict k v
346−redden t = case t of
347− RBEmpty _ -> Native.Error.raise "can't make a Leaf red"
348− RBNode _ k v l r -> RBNode Red k v l r
349−
350−{-| Apply a function to all values in a dictionary. -}
351−map : (a -> b) -> Dict comparable a -> Dict comparable b
352−map f t =
353− case t of
354− RBEmpty LBlack -> RBEmpty LBlack
355− RBNode c k v l r -> RBNode c k (f v) (map f l) (map f r)
356−
357−{-| Fold over the key-value pairs in a dictionary, in order from lowest
358−key to highest key. -}
359−foldl : (comparable -> v -> b -> b) -> b -> Dict comparable v -> b
360−foldl f acc t =
361− case t of
362− RBEmpty LBlack -> acc
363− RBNode _ k v l r -> foldl f (f k v (foldl f acc l)) r
364−
365−{-| Fold over the key-value pairs in a dictionary, in order from highest
366−key to lowest key. -}
367−foldr : (comparable -> v -> b -> b) -> b -> Dict comparable v -> b
368−foldr f acc t =
369− case t of
370− RBEmpty LBlack -> acc
371− RBNode _ k v l r -> foldr f (f k v (foldr f acc r)) l
372−
373−{-| Combine two dictionaries. If there is a collision, preference is given
374−to the first dictionary. -}
375−union : Dict comparable v -> Dict comparable v -> Dict comparable v
376−union t1 t2 = foldl insert t2 t1
377−
378−{-| Keep a key-value pair when its key appears in the second dictionary.
379−Preference is given to values in the first dictionary. -}
380−intersect : Dict comparable v -> Dict comparable v -> Dict comparable v
381−intersect t1 t2 = filter (\k _ -> k `member` t2) t1
382−
383−{-| Keep a key-value pair when its key does not appear in the second dictionary.
384−Preference is given to the first dictionary. -}
385−diff : Dict comparable v -> Dict comparable v -> Dict comparable v
386−diff t1 t2 = foldl (\k v t -> remove k t) t1 t2
387−
388−{-| Get all of the keys in a dictionary. -}
389−keys : Dict comparable v -> [comparable]
390−keys t = foldr (\k v acc -> k :: acc) [] t
391−
392−{-| Get all of the values in a dictionary. -}
393−values : Dict comparable v -> [v]
394−values t = foldr (\k v acc -> v :: acc) [] t
395−
396−{-| Convert a dictionary into an association list of key-value pairs. -}
397−toList : Dict comparable v -> [(comparable,v)]
398−toList t = foldr (\k v acc -> (k,v) :: acc) [] t
399−
400−{-| Convert an association list into a dictionary. -}
401−fromList : [(comparable,v)] -> Dict comparable v
402−fromList assocs = List.foldl (\(k,v) d -> insert k v d) empty assocs
403−
404−{-| Keep a key-value pair when it satisfies a predicate. -}
405−filter : (comparable -> v -> Bool) -> Dict comparable v -> Dict comparable v
406−filter p dict =
407− let add k v t = if p k v then insert k v t else t
408− in foldl add empty dict
409−
410−{-| Partition a dictionary according to a predicate. The first dictionary
411−contains all key-value pairs which satisfy the predicate, and the second
412−contains the rest.
413−-}
414−partition : (comparable -> v -> Bool) -> Dict comparable v -> (Dict comparable v, Dict comparable v)
415−partition p dict =
416− let add k v (t1, t2) = if p k v
417− then (insert k v t1, t2)
418− else (t1, insert k v t2)
419− in foldl add (empty, empty) dict
libraries/Either.elmdeleted−91
@@ -1,91 +0,0 @@
1−module Either where
2−
3−{-| Represents any data that can take two different types.
4−
5−# Type and Constructors
6−@docs Either
7−
8−# Taking Eithers apart
9−@docs either, isLeft, isRight
10−
11−# Eithers and Lists
12−@docs lefts, rights, partition
13−
14−-}
15−
16−import List
17−import List ((::))
18−
19−{-| Represents any data that can take two forms. For example, a user ID may be
20−either an `Int` or a `String`.
21−
22−This can also be used for error handling `(Either String a)` where
23−error messages are stored on the left, and the correct values
24−(&ldquo;right&rdquo; values) are stored on the right.
25−-}
26−data Either a b = Left a | Right b
27−
28−{-| Apply the first function to a `Left` and the second function to a `Right`.
29−This allows the extraction of a value from an `Either`.
30−
31− either (\n -> n + 1) sqrt (Left 4) == 5
32− either (\n -> n + 1) sqrt (Right 4) == 2
33−
34− map : (a -> b) -> Either err a -> Either err b
35− map f e = either Left (\x -> Right (f x)) e
36−-}
37−either : (a -> c) -> (b -> c) -> Either a b -> c
38−either f g e = case e of { Left x -> f x ; Right y -> g y }
39−
40−{-| True if the value is a `Left`.
41−
42− isLeft (Left "Cat") == True
43− isLeft (Right 1123) == False
44−-}
45−isLeft : Either a b -> Bool
46−isLeft e = case e of { Left _ -> True ; _ -> False }
47−
48−{-| True if the value is a `Right`.
49−
50− isRight (Left "Cat") == False
51− isRight (Right 1123) == True
52−-}
53−isRight : Either a b -> Bool
54−isRight e = case e of { Right _ -> True ; _ -> False }
55−
56−{-| Keep only the values held in `Left` values.
57−
58− lefts [Left 3, Right 'a', Left 5, Right "eight"] == [3,5]
59−-}
60−lefts : [Either a b] -> [a]
61−lefts es = List.foldr consLeft [] es
62−
63−{-| Keep only the values held in `Right` values.
64−
65− rights [Left 3, Right 'a', Left 5, Right 'b'] == ['a','b']
66−-}
67−rights : [Either a b] -> [b]
68−rights es = List.foldr consRight [] es
69−
70−{-| Split into two lists, lefts on the left and rights on the right. So we
71−have the equivalence: `(partition es == (lefts es, rights es))`
72−
73− partition [Left 3, Right 'a', Left 5, Right 'b'] == ([3,5],['a','b'])
74−-}
75−partition : [Either a b] -> ([a],[b])
76−partition es = List.foldr consEither ([],[]) es
77−
78−consLeft e vs =
79− case e of
80− Left v -> v::vs
81− Right _ -> vs
82−
83−consRight e vs =
84− case e of
85− Left _ -> vs
86− Right v -> v::vs
87−
88−consEither e (ls,rs) =
89− case e of
90− Left l -> (l::ls,rs)
91− Right r -> (ls,r::rs)
libraries/Graphics/Collage.elmdeleted−261
@@ -1,261 +0,0 @@
1−module Graphics.Collage where
2−
3−{-| The collage API is for freeform graphics. You can move, rotate, scale, etc.
4−all sorts of forms including lines, shapes, images, and elements.
5−
6−# Unstructured Graphics
7−@docs collage
8−
9−# Creating Forms
10−@docs toForm, filled, textured, gradient, outlined, traced
11−
12−# Transforming Forms
13−@docs move, moveX, moveY, scale, rotate, alpha
14−
15−# Grouping Forms
16−Grouping forms makes it easier to write modular graphics code. You can create
17−a form that is a composite of many subforms. From there it is easy to transform
18−it as a single unit.
19−
20−@docs group, groupTransform
21−
22−# Shapes
23−@docs rect, oval, square, circle, ngon, polygon
24−
25−# Paths
26−@docs segment, path
27−
28−# Line Styles
29−@docs solid, dashed, dotted, LineStyle, LineCap, LineJoin, defaultLine
30−
31−-}
32−
33−import Basics (..)
34−import List
35−import Either (Either(Left, Right))
36−import Transform2D (Transform2D)
37−import Transform2D as T
38−import Native.Graphics.Collage
39−import Graphics.Element (Element)
40−import Color (Color, black, Gradient)
41−import Maybe (Maybe)
42−
43−type Form = {
44− theta : Float,
45− scale : Float,
46− x : Float,
47− y : Float,
48− alpha : Float,
49− form : BasicForm
50− }
51−
52−data FillStyle
53− = Solid Color
54− | Texture String
55− | Grad Gradient
56−
57−{-| The shape of the ends of a line. -}
58−data LineCap = Flat | Round | Padded
59−
60−{-| The shape of the &ldquo;joints&rdquo; of a line, where each line segment
61−meets. `Sharp` takes an argument to limit the length of the joint. This
62−defaults to 10.
63−-}
64−data LineJoin = Smooth | Sharp Float | Clipped
65−
66−{-| All of the attributes of a line style. This lets you build up a line style
67−however you want. You can also update existing line styles with record updates.
68−-}
69−type LineStyle = {
70− color : Color,
71− width : Float,
72− cap : LineCap,
73− join : LineJoin,
74− dashing : [Int],
75− dashOffset : Int
76− }
77−
78−{-| The default line style, which is solid black with flat caps and sharp joints.
79−You can use record updates to build the line style you
80−want. For example, to make a thicker line, you could say:
81−
82− { defaultLine | width <- 10 }
83−-}
84−defaultLine : LineStyle
85−defaultLine = {
86− color = black,
87− width = 1,
88− cap = Flat,
89− join = Sharp 10,
90− dashing = [],
91− dashOffset = 0
92− }
93−
94−{-| Create a solid line style with a given color. -}
95−solid : Color -> LineStyle
96−solid clr = { defaultLine | color <- clr }
97−
98−{-| Create a dashed line style with a given color. Dashing equals `[8,4]`. -}
99−dashed : Color -> LineStyle
100−dashed clr = { defaultLine | color <- clr, dashing <- [8,4] }
101−
102−{-| Create a dotted line style with a given color. Dashing equals `[3,3]`. -}
103−dotted : Color -> LineStyle
104−dotted clr = { defaultLine | color <- clr, dashing <- [3,3] }
105−
106−data BasicForm
107− = FPath LineStyle Path
108− | FShape (Either LineStyle FillStyle) Shape
109− | FImage Int Int (Int,Int) String
110− | FElement Element
111− | FGroup Transform2D [Form]
112−
113−form : BasicForm -> Form
114−form f = { theta=0, scale=1, x=0, y=0, alpha=1, form=f }
115−
116−fill style shape = form (FShape (Right style) shape)
117−
118−{-| Create a filled in shape. -}
119−filled : Color -> Shape -> Form
120−filled color shape = fill (Solid color) shape
121−
122−{-| Create a textured shape. The texture is described by some url and is
123−tiled to fill the entire shape.
124−-}
125−textured : String -> Shape -> Form
126−textured src shape = fill (Texture src) shape
127−
128−{-| Fill a shape with a [gradient](/library/Color.elm#linear). -}
129−gradient : Gradient -> Shape -> Form
130−gradient grad shape = fill (Grad grad) shape
131−
132−{-| Outline a shape with a given line style. -}
133−outlined : LineStyle -> Shape -> Form
134−outlined style shape = form (FShape (Left style) shape)
135−
136−{-| Trace a path with a given line style. -}
137−traced : LineStyle -> Path -> Form
138−traced style path = form (FPath style path)
139−
140−{-| Create a sprite from a sprite sheet. It cuts out a rectangle
141−at a given position.
142−-}
143−sprite : Int -> Int -> (Int,Int) -> String -> Form
144−sprite w h pos src = form (FImage w h pos src)
145−
146−{-| Turn any `Element` into a `Form`. This lets you use text, gifs, and video
147−in your collage. This means you can move, rotate, and scale
148−an `Element` however you want.
149−-}
150−toForm : Element -> Form
151−toForm e = form (FElement e)
152−
153−{-| Flatten many forms into a single `Form`. This lets you move and rotate them
154−as a single unit, making it possible to build small, modular components.
155−-}
156−group : [Form] -> Form
157−group fs = form (FGroup T.identity fs)
158−
159−{-| Flatten many forms into a single `Form` and then apply a matrix
160−transformation.
161−-}
162−groupTransform : Transform2D -> [Form] -> Form
163−groupTransform matrix fs = form (FGroup matrix fs)
164−
165−{-| Move a form by the given amount. This is a relative translation so
166−`(move (10,10) form)` would move `form` ten pixels up and ten pixels to the
167−right.
168−-}
169−move : (Float,Float) -> Form -> Form
170−move (x,y) f = { f | x <- f.x + x, y <- f.y + y }
171−
172−{-| Move a shape in the x direction. This is relative so `(moveX 10 form)` moves
173−`form` 10 pixels to the right.
174−-}
175−moveX : Float -> Form -> Form
176−moveX x f = { f | x <- f.x + x }
177−
178−{-| Move a shape in the y direction. This is relative so `(moveY 10 form)` moves
179−`form` upwards by 10 pixels.
180−-}
181−moveY : Float -> Form -> Form
182−moveY y f = { f | y <- f.y + y }
183−
184−{-| Scale a form by a given factor. Scaling by 2 doubles the size.
185−-}
186−scale : Float -> Form -> Form
187−scale s f = { f | scale <- f.scale * s }
188−
189−{-| Rotate a form by a given angle. Rotate takes standard Elm angles (radians)
190−and turns things counterclockwise. So to turn `form` 30&deg; to the left
191−you would say, `(rotate (degrees 30) form)`.
192−-}
193−rotate : Float -> Form -> Form
194−rotate t f = { f | theta <- f.theta + t }
195−
196−{-| Set the alpha of a `Form`. The default is 1, and 0 is totally transparent. -}
197−alpha : Float -> Form -> Form
198−alpha a f = { f | alpha <- a }
199−
200−{-| A collage is a collection of 2D forms. There are no strict positioning
201−relationships between forms, so you are free to do all kinds of 2D graphics.
202−-}
203−collage : Int -> Int -> [Form] -> Element
204−collage = Native.Graphics.Collage.collage
205−
206−
207−type Path = [(Float,Float)]
208−
209−{-| Create a path that follows a sequence of points. -}
210−path : [(Float,Float)] -> Path
211−path ps = ps
212−
213−{-| Create a path along a given line segment. -}
214−segment : (Float,Float) -> (Float,Float) -> Path
215−segment p1 p2 = [p1,p2]
216−
217−type Shape = [(Float,Float)]
218−
219−{-| Create an arbitrary polygon by specifying its corners in order.
220−`polygon` will automatically close all shapes, so the given list
221−of points does not need to start and end with the same position.
222−-}
223−polygon : [(Float,Float)] -> Shape
224−polygon points = points
225−
226−{-| A rectangle with a given width and height. -}
227−rect : Float -> Float -> Shape
228−rect w h = let hw = w/2
229− hh = h/2
230− in [ (0-hw,0-hh), (0-hw,hh), (hw,hh), (hw,0-hh) ]
231−
232−{-| A square with a given edge length. -}
233−square : Float -> Shape
234−square n = rect n n
235−
236−{-| An oval with a given width and height. -}
237−oval : Float -> Float -> Shape
238−oval w h =
239− let n = 50
240− t = 2 * pi / n
241− hw = w/2
242− hh = h/2
243− f i = (hw * cos (t*i), hh * sin (t*i))
244− in List.map f [0..n-1]
245−
246−{-| A circle with a given radius. -}
247−circle : Float -> Shape
248−circle r = oval (2*r) (2*r)
249−
250−{-| A regular polygon with N sides. The first argument specifies the number
251−of sides and the second is the radius. So to create a pentagon with radius
252−30 you would say:
253−
254− ngon 5 30
255−-}
256−ngon : Int -> Float -> Shape
257−ngon n r =
258− let m = toFloat n
259− t = 2 * pi / m
260− f i = ( r * cos (t*i), r * sin (t*i) )
261− in List.map f [0..m-1]
libraries/Graphics/Element.elmdeleted−312
@@ -1,312 +0,0 @@
1−module Graphics.Element where
2−{-| Graphical elements that snap together to build complex widgets and layouts.
3−Each Element is a rectangle with a known width and height, making them easy to
4−combine and position.
5−
6−# Images
7−@docs image, fittedImage, croppedImage, tiledImage
8−
9−# Styling
10−@docs width, height, size, color, opacity, link, tag
11−
12−# Inspection
13−@docs widthOf, heightOf, sizeOf
14−
15−# Layout
16−@docs flow, up, down, left, right, inward, outward
17−
18−## Layout Aliases
19−There are also some convenience functions for working
20−with `flow` in specific cases:
21−
22−@docs layers, above, below, beside
23−
24−# Positioning
25−@docs empty, spacer, container
26−
27−## Specific Positions
28−
29−To create a `Position` you can use any of the built-in positions
30−which cover nine common positions.
31−@docs middle, midTop, midBottom, midLeft, midRight, topLeft, topRight,
32− bottomLeft, bottomRight
33−
34−If you need more precision, you can create custom positions.
35−
36−@docs absolute, relative, middleAt, midTopAt, midBottomAt, midLeftAt,
37− midRightAt, topLeftAt, topRightAt, bottomLeftAt, bottomRightAt
38−-}
39−
40−import Basics (..)
41−import Native.Utils
42−import List as List
43−import Color (..)
44−import Maybe ( Maybe(..) )
45−
46−type Properties = {
47− id : Int,
48− width : Int,
49− height : Int,
50− opacity : Float,
51− color : Maybe Color,
52− href : String,
53− tag : String,
54− hover : (),
55− click : ()
56− }
57−
58−type Element = { props : Properties, element : ElementPrim }
59−
60−{-| An Element that takes up no space. Good for things that appear conditionally:
61−
62− flow down [ img1, if showMore then img2 else empty ]
63−-}
64−empty : Element
65−empty = spacer 0 0
66−
67−{-| Get the width of an Element -}
68−widthOf : Element -> Int
69−widthOf e = e.props.width
70−
71−{-| Get the height of an Element -}
72−heightOf : Element -> Int
73−heightOf e = e.props.height
74−
75−{-| Get the width and height of an Element -}
76−sizeOf : Element -> (Int,Int)
77−sizeOf e = (e.props.width, e.props.height)
78−
79−{-| Create an `Element` with a given width. -}
80−width : Int -> Element -> Element
81−width nw e =
82− let p = e.props
83− props = case e.element of
84− Image _ w h _ -> {p| height <- round (toFloat h / toFloat w * toFloat nw) }
85− RawHtml -> {p| height <- snd (Native.Utils.htmlHeight nw e.element) }
86− _ -> p
87− in { element=e.element, props={ props | width <- nw } }
88−
89−{-| Create an `Element` with a given height. -}
90−height : Int -> Element -> Element
91−height nh e =
92− let p = e.props
93− props = case e.element of
94− Image _ w h _ -> {p| width <- round (toFloat w / toFloat h * toFloat nh) }
95− _ -> p
96− in { element=e.element, props={ p | height <- nh} }
97−
98−{-| Create an `Element` with a new width and height. -}
99−size : Int -> Int -> Element -> Element
100−size w h e = height h (width w e)
101−
102−{-| Create an `Element` with a given opacity. Opacity is a number between 0 and 1
103−where 0 means totally clear.
104−-}
105−opacity : Float -> Element -> Element
106−opacity o e = let p = e.props in { element=e.element, props={p| opacity <- o} }
107−
108−{-| Create an `Element` with a given background color. -}
109−color : Color -> Element -> Element
110−color c e = let p = e.props in
111− { element = e.element
112− , props = { p | color <- Just c}
113− }
114−
115−{-| Create an `Element` with a tag. This lets you link directly to it.
116−The element `(tag "all-about-badgers" thirdParagraph)` can be reached
117−with a link like this: `/facts-about-animals.elm#all-about-badgers`
118−-}
119−tag : String -> Element -> Element
120−tag name e = let p = e.props in
121− { element=e.element, props={p | tag <- name} }
122−
123−{-| Create an `Element` that is a hyper-link. -}
124−link : String -> Element -> Element
125−link href e = let p = e.props in
126− { element=e.element, props={p | href <- href} }
127−
128−newElement w h e =
129− { props = Properties (Native.Utils.guid ()) w h 1 Nothing "" "" () ()
130− , element = e
131− }
132−
133−data ElementPrim
134− = Image ImageStyle Int Int String
135− | Container Position Element
136− | Flow Direction [Element]
137− | Spacer
138− | RawHtml
139− | Custom -- for custom Elements implemented in JS, see collage for example
140−
141−data ImageStyle = Plain | Fitted | Cropped (Int,Int) | Tiled
142−
143−{-| Create an image given a width, height, and image source. -}
144−image : Int -> Int -> String -> Element
145−image w h src = newElement w h (Image Plain w h src)
146−
147−{-| Create a fitted image given a width, height, and image source.
148−This will crop the picture to best fill the given dimensions.
149−-}
150−fittedImage : Int -> Int -> String -> Element
151−fittedImage w h src = newElement w h (Image Fitted w h src)
152−
153−{-| Create a cropped image. Take a rectangle out of the picture starting
154−at the given top left coordinate. If you have a 140-by-140 image,
155−the following will cut a 100-by-100 square out of the middle of it.
156−
157− croppedImage (20,20) 100 100 "yogi.jpg"
158−-}
159−croppedImage : (Int,Int) -> Int -> Int -> String -> Element
160−croppedImage pos w h src =
161− newElement w h (Image (Cropped pos) w h src)
162−
163−tiledImage : Int -> Int -> String -> Element
164−tiledImage w h src =
165− newElement w h (Image Tiled w h src)
166−
167−data Three = P | Z | N
168−data Pos = Absolute Int | Relative Float
169−type Position = { horizontal : Three, vertical : Three, x : Pos, y : Pos }
170−
171−{-| Put an element in a container. This lets you position the element really
172−easily, and there are tons of ways to set the `Position`.
173−To center `element` exactly in a 300-by-300 square you would say:
174−
175− container 300 300 middle element
176−
177−By setting the color of the container, you can create borders.
178−-}
179−container : Int -> Int -> Position -> Element -> Element
180−container w h pos e = newElement w h (Container pos e)
181−
182−{-| Create an empty box. This is useful for getting your spacing right and
183−for making borders.
184−-}
185−spacer : Int -> Int -> Element
186−spacer w h = newElement w h Spacer
187−
188−data Direction = DUp | DDown | DLeft | DRight | DIn | DOut
189−
190−{-| Have a list of elements flow in a particular direction.
191−The `Direction` starts from the first element in the list.
192−
193− flow right [a,b,c]
194−
195− +---+---+---+
196− | a | b | c |
197− +---+---+---+
198−-}
199−flow : Direction -> [Element] -> Element
200−flow dir es =
201− let ws = List.map widthOf es
202− hs = List.map heightOf es
203− newFlow w h = newElement w h (Flow dir es)
204− in
205− if es == [] then empty else
206− case dir of
207− DUp -> newFlow (List.maximum ws) (List.sum hs)
208− DDown -> newFlow (List.maximum ws) (List.sum hs)
209− DLeft -> newFlow (List.sum ws) (List.maximum hs)
210− DRight -> newFlow (List.sum ws) (List.maximum hs)
211− DIn -> newFlow (List.maximum ws) (List.maximum hs)
212− DOut -> newFlow (List.maximum ws) (List.maximum hs)
213−
214−{-| Stack elements vertically.
215−To put `a` above `b` you would say: ``a `above` b``
216−-}
217−above : Element -> Element -> Element
218−above hi lo =
219− newElement (max (widthOf hi) (widthOf lo))
220− (heightOf hi + heightOf lo)
221− (Flow DDown [hi,lo])
222−
223−{-| Stack elements vertically.
224−To put `a` below `b` you would say: ``a `below` b``
225−-}
226−below : Element -> Element -> Element
227−below lo hi =
228− newElement (max (widthOf hi) (widthOf lo))
229− (heightOf hi + heightOf lo)
230− (Flow DDown [hi,lo])
231−
232−{-| Put elements beside each other horizontally.
233−To put `a` beside `b` you would say: ``a `beside` b``
234−-}
235−beside : Element -> Element -> Element
236−beside lft rht =
237− newElement (widthOf lft + widthOf rht)
238− (max (heightOf lft) (heightOf rht))
239− (Flow right [lft,rht])
240−
241−{-| Layer elements on top of each other, starting from the bottom:
242−`layers == flow outward`
243−-}
244−layers : [Element] -> Element
245−layers es =
246− let ws = List.map widthOf es
247− hs = List.map heightOf es
248− in newElement (List.maximum ws) (List.maximum hs) (Flow DOut es)
249−
250−
251−-- Repetitive things --
252−
253−absolute : Int -> Pos
254−absolute = Absolute
255−relative : Float -> Pos
256−relative = Relative
257−
258−middle : Position
259−middle = { horizontal=Z, vertical=Z, x=Relative 0.5, y=Relative 0.5 }
260−topLeft : Position
261−topLeft = { horizontal=N, vertical=P, x=Absolute 0, y=Absolute 0 }
262−topRight : Position
263−topRight = { topLeft | horizontal <- P }
264−bottomLeft : Position
265−bottomLeft = { topLeft | vertical <- N }
266−bottomRight : Position
267−bottomRight = { bottomLeft | horizontal <- P }
268−midLeft : Position
269−midLeft = { middle | horizontal <- N, x <- Absolute 0 }
270−midRight : Position
271−midRight = { midLeft | horizontal <- P }
272−midTop : Position
273−midTop = { middle | vertical <- P, y <- Absolute 0 }
274−midBottom : Position
275−midBottom = { midTop | vertical <- N }
276−
277−middleAt : Pos -> Pos -> Position
278−middleAt x y = { horizontal = Z, vertical = Z, x = x, y = y }
279−topLeftAt : Pos -> Pos -> Position
280−topLeftAt x y = { horizontal = N, vertical = P, x = x, y = y }
281−topRightAt : Pos -> Pos -> Position
282−topRightAt x y = { horizontal = P, vertical = P, x = x, y = y }
283−bottomLeftAt : Pos -> Pos -> Position
284−bottomLeftAt x y = { horizontal = N, vertical = N, x = x, y = y }
285−bottomRightAt : Pos -> Pos -> Position
286−bottomRightAt x y = { horizontal = P, vertical = N, x = x, y = y }
287−midLeftAt : Pos -> Pos -> Position
288−midLeftAt x y = { horizontal = N, vertical = Z, x = x, y = y }
289−midRightAt : Pos -> Pos -> Position
290−midRightAt x y = { horizontal = P, vertical = Z, x = x, y = y }
291−midTopAt : Pos -> Pos -> Position
292−midTopAt x y = { horizontal = Z, vertical = P, x = x, y = y }
293−midBottomAt : Pos -> Pos -> Position
294−midBottomAt x y = { horizontal = Z, vertical = N, x = x, y = y }
295−
296−up : Direction
297−up = DUp
298−
299−down : Direction
300−down = DDown
301−
302−left : Direction
303−left = DLeft
304−
305−right : Direction
306−right = DRight
307−
308−inward : Direction
309−inward = DIn
310−
311−outward : Direction
312−outward = DOut
libraries/Graphics/Input.elmdeleted−178
@@ -1,178 +0,0 @@
1−module Graphics.Input where
2−{-| This module is for creating standard input widgets such as buttons and
3−text fields. All functions in this library follow a general pattern in which
4−you create an `Input` that many elements can report to:
5−
6−```haskell
7−clicks : Input ()
8−clicks = input ()
9−
10−clickableYogi : Element
11−clickableYogi = clickable clicks.handle () (image 40 40 "/yogi.jpg")
12−```
13−
14−Whenever the user clicks on the resulting `clickableYogi` element, it sends an
15−update to the `clicks` input. You will see this pattern again and again in
16−examples in this library, so just read on to get a better idea of how it works!
17−
18−# Creating Inputs
19−@docs Input, input
20−
21−# Basic Input Elements
22−
23−To learn about text fields, see the
24−[`Graphics.Input.Field`](Graphics-Input-Field) library.
25−
26−@docs button, customButton, checkbox, dropDown
27−
28−# Clicks and Hovers
29−@docs clickable, hoverable
30−
31−-}
32−
33−import Signal (Signal)
34−import Graphics.Element (Element)
35−import Native.Graphics.Input
36−
37−{-| This is the key abstraction of this library. An `Input` is a record
38−of two fields:
39−
40− 1. `signal` &mdash; all values coming to this input from &ldquo;the world&rdquo;
41− 2. `handle` &mdash; a way to refer to this particular input and send it values
42−
43−This will make more sense as you see more examples.
44−-}
45−type Input a = { signal : Signal a, handle : Handle a }
46−
47−data Handle a = Handle
48−
49−{-| This creates a new `Input`. You provide a single argument that will serve
50−as the initial value of the input&rsquo;s `signal`. For example:
51−
52− numbers : Input Int
53− numbers = input 42
54−
55−The initial value of `numbers.signal` is 42, and you will be able
56−to pipe updates to the input using `numbers.handle`.
57−
58−Note: This is an inherently impure function. Specifically, `(input ())` and
59−`(input ())` are actually two different inputs with different signals and handles.
60−-}
61−input : a -> Input a
62−input = Native.Graphics.Input.input
63−
64−{-| Create a standard button. The following example begins making a basic
65−calculator:
66−
67− data Keys = Number Int | Plus | Minus | Clear
68−
69− keys : Input Keys
70− keys = input Clear
71−
72− calculator : Element
73− calculator =
74− flow right [ button keys.handle (Number 1) "1"
75− , button keys.handle (Number 2) "2"
76− , button keys.handle Plus "+"
77− ]
78−
79−If the user presses the "+" button, `keys.signal` will update to `Plus`. If the
80−users presses "2", `keys.signal` will update to `(Number 2)`.
81−-}
82−button : Handle a -> a -> String -> Element
83−button = Native.Graphics.Input.button
84−
85−{-| Same as `button` but lets you customize buttons to look however you want.
86−
87− click : Input ()
88− click = input ()
89−
90− prettyButton : Element
91− prettyButton =
92− customButton click.handle ()
93− (image 100 40 "/button_up.jpg")
94− (image 100 40 "/button_hover.jpg")
95− (image 100 40 "/button_down.jpg")
96−-}
97−customButton : Handle a -> a -> Element -> Element -> Element -> Element
98−customButton = Native.Graphics.Input.customButton
99−
100−{-| Create a checkbox. The following example creates three synced checkboxes:
101−
102− check : Input Bool
103− check = input False
104−
105− boxes : Bool -> Element
106− boxes checked =
107− let box = container 40 40 middle (checkbox check.handle id checked)
108− in flow right [ box, box, box ]
109−
110− main : Signal Element
111− main = boxes <~ check.signal
112−-}
113−checkbox : Handle a -> (Bool -> a) -> Bool -> Element
114−checkbox = Native.Graphics.Input.checkbox
115−
116−{-| Create a drop-down menu. The following drop-down lets you choose your
117−favorite British sport:
118−
119− data Sport = Football | Cricket | Snooker
120−
121− sport : Input (Maybe Sport)
122− sport = input Nothing
123−
124− sportDropDown : Element
125− sportDropDown =
126− dropDown sport.handle
127− [ ("" , Nothing)
128− , ("Football", Just Football)
129− , ("Cricket" , Just Cricket)
130− , ("Snooker" , Just Snooker)
131− ]
132−
133−If the user selects "Football" from the drop down menue, `sport.signal`
134−will update to `Just Football`.
135−-}
136−dropDown : Handle a -> [(String,a)] -> Element
137−dropDown = Native.Graphics.Input.dropDown
138−
139−{-| Detect mouse hovers over a specific `Element`. In the following example,
140−we will create a hoverable picture called `cat`.
141−
142− hover : Input Bool
143− hover = input False
144−
145− cat : Element
146− cat = image 30 30 "/cat.jpg"
147− |> hoverable hover.handle id
148−
149−When the mouse hovers above the `cat` element, `hover.signal` will become
150−`True`. When the mouse leaves it, `hover.signal` will become `False`.
151−-}
152−hoverable : Handle a -> (Bool -> a) -> Element -> Element
153−hoverable = Native.Graphics.Input.hoverable
154−
155−{-| Detect mouse clicks on a specific `Element`. In the following example,
156−we will create a clickable picture called `cat`.
157−
158− data Picture = Cat | Hat
159−
160− picture : Input Picture
161− picture = input Cat
162−
163− cat : Element
164− cat = image 30 30 "/cat.jpg"
165− |> clickable picture.handle Cat
166−
167− hat : Element
168− hat = image 30 30 "/hat.jpg"
169− |> clickable picture.handle Hat
170−
171−When the user clicks on the `cat` element, `picture.signal` receives
172−an update containing the value `Cat`. When the user clicks on the `hat` element,
173−`picture.signal` receives an update containing the value `Hat`. This lets you
174−distinguish which element was clicked. In a more complex example, they could be
175−distinguished with IDs or more complex data structures.
176−-}
177−clickable : Handle a -> a -> Element -> Element
178−clickable = Native.Graphics.Input.clickable
libraries/Graphics/Input/Field.elmdeleted−170
@@ -1,170 +0,0 @@
1−module Graphics.Input.Field where
2−{-| This library provides an API for creating and updating text fields.
3−Text fields use exactly the same approach as [`Graphics.Input`](Graphics-Input)
4−for modelling user input, allowing you to keep track of new events and update
5−text fields programmatically.
6−
7−# Create Fields
8−@docs field, password, email
9−
10−# Field Content
11−@docs Content, Selection, Direction, noContent
12−
13−# Field Style
14−@docs Style, Outline, noOutline, Highlight, noHighlight, Dimensions, uniformly
15−-}
16−
17−import Color (Color)
18−import Color
19−import Graphics.Element (Element)
20−import Graphics.Input (Input, Handle)
21−import Native.Graphics.Input
22−import Text
23−
24−{-| Create uniform dimensions:
25−
26− uniformly 4 == { left=4, right=4, top=4, bottom=4 }
27−
28−The following example creates an outline where the left, right, top, and bottom
29−edges all have width 1:
30−
31− Outline grey (uniformly 1) 4
32−-}
33−uniformly : Int -> Dimensions
34−uniformly n = Dimensions n n n n
35−
36−{-| For setting dimensions of a field's padding or outline. The left, right,
37−top, and bottom may all have different sizes. The following example creates
38−dimensions such that the left and right are twice as wide as the top and bottom:
39−
40− myDimensions : Int -> Dimensions
41− myDimensions n = { left = 2 * n, right = 2 * n, top = n, bottom = n }
42−-}
43−type Dimensions = { left:Int, right:Int, top:Int, bottom:Int }
44−
45−{-| A field can have a outline around it. This lets you set its color, width,
46−and radius. The radius allows you to round the corners of your field. Set the
47−width to zero to make it invisible. Here is an example outline that is grey
48−and thin with slightly rounded corners:
49−
50− { color = grey, width = uniformly 1, radius = 4 }
51−-}
52−type Outline = { color:Color, width:Dimensions, radius:Int }
53−
54−{-| An outline with zero width, so you cannot see it. -}
55−noOutline : Outline
56−noOutline = Outline Color.grey (uniformly 0) 0
57−
58−{-| When a field has focus, it has a blue highlight around it by default. The
59−`Highlight` lets you set the `color` and `width` of this highlight. Set the
60−`width` to zero to turn the highlight off. Here is an example highlight that
61−is blue and thin:
62−
63− { color = blue, width = 1 }
64−-}
65−type Highlight = { color:Color, width:Int }
66−
67−{-| An highlight with zero width, so you cannot see it. -}
68−noHighlight : Highlight
69−noHighlight = Highlight Color.blue 0
70−
71−{-| Describe the style of a text box. `style` describes the style of the text
72−itself using [`Text.Style`](/Text#Style). `highlight` describes the glowing blue
73−highlight that shows up when the field has focus. `outline` describes the line
74−surrounding the text field, and `padding` adds whitespace between the `outline`
75−and the text.
76−
77−The width and height of the text box *includes* the `padding` and `outline`.
78−Say we have a text box that is 40 pixels tall. It has a uniform outline of
79−1 pixel and a uniform padding of 5 pixels. Both of these must be subtracted
80−from the total height to determine how much room there is for text. The
81−`padding` and `outline` appear on the top and bottom, so there will be 28
82−vertical pixels remaining for the text (40 - 1 - 5 - 5 - 1).
83−-}
84−type Style =
85− { padding : Dimensions
86− , outline : Outline
87− , highlight : Highlight
88− , style : Text.Style
89− }
90−
91−{-| The default style for a text field. The outline is `Color.grey` with width
92−1 and radius 2. The highlight is `Color.blue` with width 1, and the default
93−text color is black.
94−-}
95−defaultStyle : Style
96−defaultStyle =
97− { padding = uniformly 4
98− , outline = Outline Color.grey (uniformly 1) 2
99− , highlight = Highlight Color.blue 1
100− , style = Text.defaultStyle
101− }
102−
103−{-| Represents the current content of a text field. For example:
104−
105− content = Content "She sells sea shells" (Selection 0 3 Backward)
106−
107−This means the user highlighted the substring `"She"` backwards. The value of
108−`content.string` is `"She sells sea shells"`.
109−-}
110−type Content = { string:String, selection:Selection }
111−
112−{-| The selection within a text field. `start` is never greater than `end`:
113−
114− Selection 0 0 Forward -- cursor precedes all characters
115−
116− Selection 5 9 Backward -- highlighting characters starting after
117− -- the 5th and ending after the 9th
118−-}
119−type Selection = { start:Int, end:Int, direction:Direction }
120−
121−{-| The direction of selection. When the user highlights a selection in a text
122−field, they must do it in a particular direction. This determines which end of
123−the selection moves when they change the selection by pressing Shift-Left or
124−Shift-Right.
125−-}
126−data Direction = Forward | Backward
127−
128−{-| A field with no content:
129−
130− Content "" (Selection 0 0 Forward)
131−-}
132−noContent : Content
133−noContent = Content "" (Selection 0 0 Forward)
134−
135−{-| Create a text field. The following example creates a time-varying element
136−called `nameField`. As the user types their name, the field will be updated
137−to match what they have entered.
138−
139− name : Input Content
140− name = input noContent
141−
142− nameField : Signal Element
143− nameField = field defaultStyle name.handle id "Name" <~ name.signal
144−
145−When we use the `field` function, we first give it a visual style. This is
146−the first argument so that it is easier to define your own custom field
147−(`myField = field myStyle`). The next two arguments are a `Handle` and a
148−handler function that processes or augments events before sending them along
149−to the associated `Input`. In the example above we use the `id` function to
150−pass events along unchanged to the `name` `Input`. We then provide the
151−place-holder message to use when no input has been provided yet. Finally,
152−we give the current `Content` of the field. This argument is last because
153−it is most likely to change frequently, making function composition easier.
154−-}
155−field : Style -> Handle a -> (Content -> a) -> String -> Content -> Element
156−field = Native.Graphics.Input.field
157−
158−{-| Same as `field` but the UI element blocks out each characters. -}
159−password : Style -> Handle a -> (Content -> a) -> String -> Content -> Element
160−password = Native.Graphics.Input.password
161−
162−{-| Same as `field` but it adds an annotation that this field is for email
163−addresses. This is helpful for auto-complete and for mobile users who may
164−get a custom keyboard with an `@` and `.com` button.
165−-}
166−email : Style -> Handle a -> (Content -> a) -> String -> Content -> Element
167−email = Native.Graphics.Input.email
168−
169−-- area : Handle a -> (Content -> a) -> Handle b -> ((Int,Int) -> b) -> (Int,Int) -> String -> Content -> Element
170−-- area = Native.Graphics.Input.area
libraries/Http.elmdeleted−54
@@ -1,54 +0,0 @@
1−module Http where
2−{-| A library for asynchronous HTTP requests. See the `WebSocket`
3−library if you have very strict latency requirements.
4−
5−# Sending Requests
6−@docs send, sendGet
7−
8−# Creating Requests
9−@docs get, post, request
10−
11−# Responses
12−@docs Response
13−-}
14−
15−import Signal (..)
16−import Native.Http
17−
18−{-| The datatype for responses. Success contains only the returned message.
19−Failures contain both an error code and an error message.
20−-}
21−data Response a = Success a | Waiting | Failure Int String
22−
23−type Request a = {
24− verb : String,
25− url : String,
26− body : a,
27− headers : [(String,String)]
28− }
29−
30−{-| Create a customized request. Arguments are request type (get, post, put,
31−delete, etc.), target url, data, and a list of additional headers.
32−-}
33−request : String -> String -> String -> [(String,String)] -> Request String
34−request = Request
35−
36−{-| Create a GET request to the given url. -}
37−get : String -> Request String
38−get url = Request "GET" url "" []
39−
40−{-| Create a POST request to the given url, carrying the given data. -}
41−post : String -> String -> Request String
42−post url body = Request "POST" url body []
43−
44−{-| Performs an HTTP request with the given requests. Produces a signal
45−that carries the responses.
46−-}
47−send : Signal (Request a) -> Signal (Response String)
48−send = Native.Http.send
49−
50−{-| Performs an HTTP GET request with the given urls. Produces a signal
51−that carries the responses.
52−-}
53−sendGet : Signal String -> Signal (Response String)
54−sendGet reqs = send (lift get reqs)
libraries/JavaScript/Experimental.elmdeleted−56
@@ -1,56 +0,0 @@
1−module JavaScript.Experimental where
2−{-| A pair of very experimental functions for converting between
3−Elm records and JavaScript objects. It currently uses a best effort
4−conversion that can cause runtime errors. This API should change and
5−improve as we find its key failings.
6−
7−# Converting between Elm records and JS Objects
8−@docs toRecord, fromRecord
9−-}
10−
11−import Native.JavaScript
12−import Native.Json
13−import Json
14−
15−data RawObject = RawObject
16−
17−{-| Turn arbitrary JavaScript objects into Elm records.
18−Arrays are converted into lists, nested objects are allowed.
19−No `null` values or non-homogeneous arrays.
20−
21− -- OK objects
22− { student:"Steve", scores:[83,94,99,72] }
23− { errorLevel:10, critical:true }
24−
25− -- BAD objects
26− { answer:null }
27− { info:[true,42,'what'] }
28−-}
29−toRecord : RawObject -> a
30−toRecord = Native.JavaScript.toRecord
31−
32−{-| Turn arbitrary Elm records into JavaScript objects.
33−Lists become arrays, nested records are allowed. No ADTs.
34−
35− -- OK records
36− { student="Steve", scores=[83,94,99,72] }
37− { errorLevel=10, critical=True }
38−
39− -- BAD records
40− { answer = Nothing }
41− { result = Left "An error occurred" }
42−-}
43−fromRecord : a -> RawObject
44−fromRecord = Native.JavaScript.fromRecord
45−
46−{-| Turn a raw JavaScript object into a `Json.Value` as described in the
47−`Json` library.
48−-}
49−toJson : RawObject -> Json.Value
50−toJson = Native.Json.fromJS
51−
52−{-| Turn a `Json.Value` (as described in the `Json` library) into a raw
53−JavaScript object.
54−-}
55−fromJson : Json.Value -> RawObject
56−fromJson = Native.Json.toJS
libraries/Json.elmdeleted−49
@@ -1,49 +0,0 @@
1−
2−module Json where
3−
4−{-| Library for working with [JSON](https://en.wikipedia.org/wiki/JSON) values.
5−
6−@docs Value, fromString, toString
7−
8−-}
9−
10−import Dict
11−import Maybe (Maybe)
12−import Native.Json
13−
14−{-| This datatype can represent all valid JSON values. A `Value` can be sent
15−through ports, and the runtime will do a conversion like this:
16−
17− [2,'abc',null] == Array [Number 2, String "abc", Null]
18−
19−JSON is an intentional subset of JavaScript values which excludes functions.
20−This ensures that impure functions cannot sneak into Elm through ports.
21−-}
22−data Value
23− = String String
24− | Number Float
25− | Boolean Bool
26− | Null
27− | Array [Value]
28− | Object (Dict.Dict String Value)
29−
30−
31−{-| Convert a `Value` into a prettified string.
32−The first argument is a separator token (e.g. \" \", \"\\n\", etc.) that will
33−be used for indentation in the prettified string version of the JSON.
34−
35− toString "" Null == "null"
36− toString "" (Number 4.0) == "4.0"
37−-}
38−toString : String -> Value -> String
39−toString sep value = Native.Json.toString sep value
40−
41−{-| Parse a string representation of a proper JSON object into
42−its Elm representation.
43−
44− fromString "null" == Just Null
45− fromString "[true,3]" == Just (Array [Boolean True, Number 3])
46− fromString "{'abc':4}" == Just (Object (Dict.fromList [("abc", Number 4)]))
47−-}
48−fromString : String -> Maybe Value
49−fromString str = Native.Json.fromString str
libraries/Keyboard.elmdeleted−82
@@ -1,82 +0,0 @@
1−module Keyboard where
2−{-| Library for working with keyboard input.
3−
4−# Representing Keys
5−@docs KeyCode
6−
7−# Directions
8−@docs arrows, wasd, directions
9−
10−# Specific Keys
11−The following signals are `True` when the particular key is pressed and `False`
12−otherwise.
13−
14−@docs enter, space, ctrl, shift, alt, meta
15−
16−# General Keypresses
17−@docs isDown, keysDown, lastPressed
18−
19−-}
20−
21−import Signal (Signal)
22−import Native.Keyboard
23−
24−{-| Type alias to make it clearer what integers are supposed to represent
25−in this library. Use `Char.toCode` and `Char.fromCode` to convert key codes
26−to characters. Use the uppercase character with `toCode`.
27−-}
28−type KeyCode = Int
29−
30−{-| Custom key directions to support different locales. The order is up, down,
31−left, right.
32−-}
33−directions : KeyCode -> KeyCode -> KeyCode -> KeyCode -> Signal { x:Int, y:Int }
34−directions = Native.Keyboard.directions
35−
36−{-| A signal of records indicating which arrow keys are pressed.
37−
38−`{ x = 0, y = 0 }` when pressing no arrows.<br>
39−`{ x =-1, y = 0 }` when pressing the left arrow.<br>
40−`{ x = 1, y = 1 }` when pressing the up and right arrows.<br>
41−`{ x = 0, y =-1 }` when pressing the down, left, and right arrows.
42−-}
43−arrows : Signal { x:Int, y:Int }
44−arrows = directions 38 40 37 39
45−
46−{-| Just like the arrows signal, but this uses keys w, a, s, and d,
47−which are common controls for many computer games.
48−-}
49−wasd : Signal { x:Int, y:Int }
50−wasd = directions 87 83 65 68
51−
52−{-| Whether an arbitrary key is pressed. -}
53−isDown : KeyCode -> Signal Bool
54−isDown = Native.Keyboard.isDown
55−
56−alt : Signal Bool
57−alt = Native.Keyboard.alt
58−
59−ctrl : Signal Bool
60−ctrl = isDown 17
61−
62−{-| The meta key is the Windows key on Windows and the Command key on Mac.
63−-}
64−meta : Signal Bool
65−meta = Native.Keyboard.meta
66−
67−shift : Signal Bool
68−shift = isDown 16
69−
70−space : Signal Bool
71−space = isDown 32
72−
73−enter : Signal Bool
74−enter = isDown 13
75−
76−{-| List of keys that are currently down. -}
77−keysDown : Signal [KeyCode]
78−keysDown = Native.Keyboard.keysDown
79−
80−{-| The latest key that has been pressed. -}
81−lastPressed : Signal KeyCode
82−lastPressed = Native.Keyboard.lastPressed
libraries/List.elmdeleted−326
@@ -1,326 +0,0 @@
1−module List where
2−
3−{-| A library for manipulating lists of values. Every value in a
4−list must have the same type.
5−
6−# Basics
7−@docs (::), (++), isEmpty, length, reverse, map
8−
9−# Sub-lists
10−@docs head, tail, last, filter, take, drop
11−
12−# Putting Lists Together
13−@docs concat, join, intersperse, zip, zipWith, repeat
14−
15−# Taking Lists Apart
16−@docs partition, unzip
17−
18−# Folds
19−@docs foldr, foldl
20−
21−# Special Maps
22−@docs filterMap, concatMap, indexedMap
23−
24−# Special Folds
25−@docs sum, product, maximum, minimum, all, any, foldr1, foldl1, scanl, scanl1
26−
27−# Sorting
28−@docs sort, sortBy, sortWith
29−
30−# Additional Zips
31−@docs zip3, zip4, zip5, zipWith3, zipWith4, zipWith5
32−
33−If you can think of a legitimate use of `zipN` or `zipWithN` where `N` is 6 or
34−more, please let us know on [the
35−list](https://groups.google.com/forum/#!forum/elm-discuss). The current
36−sentiment is that it is already quite error prone once you get to 4 and
37−possibly should be approached another way.
38−-}
39−
40−import Basics (..)
41−import Maybe ( Maybe(Just,Nothing) )
42−import Native.List
43−
44−{-| Add an element to the front of a list `(1 :: [2,3] == [1,2,3])` -}
45−(::) : a -> [a] -> [a]
46−(::) = Native.List.cons
47−
48−{-| Puts two appendable things together:
49−
50− [1,1] ++ [2,3] == [1,1,2,3]
51− "abc" ++ "123" == "abc123"
52−-}
53−(++) : appendable -> appendable -> appendable
54−(++) = Native.List.append
55−
56−infixr 5 ::
57−infixr 5 ++
58−
59−{-| Extract the first element of a list. List must be non-empty.
60−`(head [1,2,3] == 1)`
61−-}
62−head : [a] -> a
63−head = Native.List.head
64−
65−{-| Extract the elements after the head of the list. List must be non-empty.
66−`(tail [1,2,3] == [2,3])`
67−-}
68−tail : [a] -> [a]
69−tail = Native.List.tail
70−
71−{-| Extract the last element of a list. List must be non-empty.
72−`(last [1,2,3] == 3)`
73−-}
74−last : [a] -> a
75−last = Native.List.last
76−
77−{-| Check if a list is empty `(isEmpty [] == True)` -}
78−isEmpty : [a] -> Bool
79−isEmpty xs =
80− case xs of
81− [] -> True
82− _ -> False
83−
84−{-| Apply a function to every element of a list: `(map sqrt [1,4,9] == [1,2,3])` -}
85−map : (a -> b) -> [a] -> [b]
86−map = Native.List.map
87−
88−{-| Same as `map` but the function is also applied to the index of each
89−element (starting at zero).
90−
91− indexedMap (,) ["Tom","Sue","Bob"] == [ (0,"Tom"), (1,"Sue"), (2,"Bob") ]
92−-}
93−indexedMap : (Int -> a -> b) -> [a] -> [b]
94−indexedMap f xs =
95− zipWith f [ 0 .. length xs - 1 ] xs
96−
97−{-| Reduce a list from the left: `(foldl (::) [] [1,2,3] == [3,2,1])` -}
98−foldl : (a -> b -> b) -> b -> [a] -> b
99−foldl = Native.List.foldl
100−
101−{-| Reduce a list from the right: `(foldr (+) 0 [1,2,3] == 6)` -}
102−foldr : (a -> b -> b) -> b -> [a] -> b
103−foldr = Native.List.foldr
104−
105−{-| Reduce a list from the left without a base case. List must be non-empty. -}
106−foldl1 : (a -> a -> a) -> [a] -> a
107−foldl1 = Native.List.foldl1
108−
109−{-| Reduce a list from the right without a base case. List must be non-empty. -}
110−foldr1 : (a -> a -> a) -> [a] -> a
111−foldr1 = Native.List.foldr1
112−
113−{-| Reduce a list from the left, building up all of the intermediate results into a list.
114−
115− scanl (+) 0 [1,2,3,4] == [0,1,3,6,10]
116−-}
117−scanl : (a -> b -> b) -> b -> [a] -> [b]
118−scanl = Native.List.scanl
119−
120−{-| Same as scanl but it doesn't require a base case. List must be non-empty.
121−
122− scanl1 (+) [1,2,3,4] == [1,3,6,10]
123−-}
124−scanl1 : (a -> a -> a) -> [a] -> [a]
125−scanl1 = Native.List.scanl1
126−
127−{-| Keep only elements that satisfy the predicate:
128−`(filter isEven [1..6] == [2,4,6])`
129−-}
130−filter : (a -> Bool) -> [a] -> [a]
131−filter = Native.List.filter
132−
133−{-| Apply a function that may succeed to all values in the list, but only keep
134−the successes.
135−
136− toInt : String -> Maybe Int
137−
138− filterMap toInt ["3", "4.0", "5", "hats"] == [3,5]
139−-}
140−filterMap : (a -> Maybe b) -> [a] -> [b]
141−filterMap f xs = foldr (maybeCons f) [] xs
142−
143−maybeCons : (a -> Maybe b) -> a -> [b] -> [b]
144−maybeCons f mx xs =
145− case f mx of
146− Just x -> x :: xs
147− Nothing -> xs
148−
149−{-| Determine the length of a list: `(length [1,2,3] == 3)` -}
150−length : [a] -> Int
151−length = Native.List.length
152−
153−{-| Reverse a list. `(reverse [1..4] == [4,3,2,1])` -}
154−reverse : [a] -> [a]
155−reverse = Native.List.reverse
156−
157−{-| Check to see if all elements satisfy the predicate. -}
158−all : (a -> Bool) -> [a] -> Bool
159−all = Native.List.all
160−
161−{-| Check to see if any elements satisfy the predicate. -}
162−any : (a -> Bool) -> [a] -> Bool
163−any = Native.List.any
164−
165−{-| Concatenate a list of appendable things:
166−
167− concat [[1,2],[3],[4,5]] == [1,2,3,4,5]
168− concat ["tree","house"] == "treehouse"
169−-}
170−concat : [appendable] -> appendable
171−concat = Native.List.concat
172−
173−{-| Map a given function onto a list and flatten the resulting lists.
174−
175− concatMap f xs == concat (map f xs)
176−-}
177−concatMap : (a -> appendable) -> [a] -> appendable
178−concatMap f list = concat (map f list)
179−
180−{-| Get the sum of the list elements. `(sum [1..4] == 10)` -}
181−sum : [number] -> number
182−sum = foldl (+) 0
183−
184−{-| Get the product of the list elements. `(product [1..4] == 24)` -}
185−product : [number] -> number
186−product = foldl (*) 1
187−
188−{-| Find the maximum element in a non-empty list: `maximum [1,4,2] == 4` -}
189−maximum : [comparable] -> comparable
190−maximum = foldl1 max
191−
192−{-| Find the minimum element in a non-empty list: `minimum [3,2,1] == 1` -}
193−minimum : [comparable] -> comparable
194−minimum = foldl1 min
195−
196−{-| Partition a list based on a predicate. The first list contains all values
197−that satisfy the predicate, and the second list contains all the value that do
198−not.
199−
200− partition (\x -> x < 3) [0..5] == ([0,1,2], [3,4,5])
201− partition isEven [0..5] == ([0,2,4], [1,3,5])
202−-}
203−partition : (a -> Bool) -> [a] -> ([a],[a])
204−partition pred =
205− let step x (ts, fs) = if pred x
206− then (x::ts, fs)
207− else (ts, x::fs)
208− in foldr step ([],[])
209−
210−{-| Combine two lists, combining them into tuples pairwise.
211−If one list is longer, the extra elements are dropped.
212−
213− zip [1,2,3] [6,7] == [(1,6),(2,7)]
214− zip == zipWith (,)
215−-}
216−zip : [a] -> [b] -> [(a,b)]
217−zip = Native.List.zip
218−
219−zip3 : [a] -> [b] -> [c] -> [(a,b,c)]
220−zip3 = Native.List.zipWith3 (,,)
221−
222−zip4 : [a] -> [b] -> [c] -> [d] -> [(a,b,c,d)]
223−zip4 = Native.List.zipWith4 (,,,)
224−
225−zip5 : [a] -> [b] -> [c] -> [d] -> [e] -> [(a,b,c,d,e)]
226−zip5 = Native.List.zipWith5 (,,,,)
227−
228−{-| Combine two lists, combining them with the given function.
229−If one list is longer, the extra elements are dropped.
230−
231− zipWith (+) [1,2,3] [1,2,3,4] == [2,4,6]
232−-}
233−zipWith : (a -> b -> c) -> [a] -> [b] -> [c]
234−zipWith = Native.List.zipWith
235−
236−zipWith3 : (a -> b -> c -> x) -> [a] -> [b] -> [c] -> [x]
237−zipWith3 = Native.List.zipWith3
238−
239−zipWith4 : (a -> b -> c -> d -> x) -> [a] -> [b] -> [c] -> [d] -> [x]
240−zipWith4 = Native.List.zipWith4
241−
242−zipWith5 : (a -> b -> c -> d -> e -> x) -> [a] -> [b] -> [c] -> [d] -> [e] -> [x]
243−zipWith5 = Native.List.zipWith5
244−
245−{-| Decompose a list of tuples.
246−
247− unzip [(0, True), (17, False), (1337, True)] == ([0,17,1337], [True,False,True])
248−-}
249−unzip : [(a,b)] -> ([a],[b])
250−unzip =
251− let step (x,y) (xs, ys) = (x::xs, y::ys)
252− in foldr step ([], [])
253−
254−{-| Places the given value between all of the lists in the second
255−argument and concatenates the result.
256−
257− join "a" ["H","w","ii","n"] == "Hawaiian"
258−-}
259−join : appendable -> [appendable] -> appendable
260−join = Native.List.join
261−
262−{-| Places the given value between all members of the given list.
263−
264− intersperse "on" ["turtles","turtles","turtles"] == ["turtles","on","turtles","on","turtles"]
265−-}
266−intersperse : a -> [a] -> [a]
267−intersperse sep xs =
268− case xs of
269− [] -> []
270− hd::tl ->
271− let step x rest = sep :: x :: rest
272− spersed = foldr step [] tl
273− in hd :: spersed
274−
275−{-| Take the first n members of a list: `(take 2 [1,2,3,4] == [1,2])` -}
276−take : Int -> [a] -> [a]
277−take = Native.List.take
278−
279−{-| Drop the first n members of a list: `(drop 2 [1,2,3,4] == [3,4])` -}
280−drop : Int -> [a] -> [a]
281−drop = Native.List.drop
282−
283−{-| Creates a list with *n* copies of a value:
284−`(repeat 3 (0,0) == [(0,0),(0,0),(0,0)]`
285−-}
286−repeat : Int -> a -> [a]
287−repeat = Native.List.repeat
288−
289−{-| Sort values from lowest to highest: `sort [3,1,5] == [1,3,5]`
290−-}
291−sort : [comparable] -> [comparable]
292−sort = Native.List.sort
293−
294−{-| Sort values by a derived property.
295−
296−```haskell
297−alice = { name="Alice", height=1.62 }
298−bob = { name="Bob" , height=1.85 }
299−chuck = { name="Chuck", height=1.76 }
300−
301−sortBy .name [chuck,alice,bob] == [alice,bob,chuck]
302−sortBy .height [chuck,alice,bob] == [alice,chuck,bob]
303−
304−sortBy String.length ["mouse","cat"] == ["cat","mouse"]
305−```
306−-}
307−sortBy : (a -> comparable) -> [a] -> [a]
308−sortBy = Native.List.sortBy
309−
310−{-| Sort values with a custom comparison function.
311−
312−```haskell
313−sortWith flippedComparison [1..5] == [5,4,3,2,1]
314−
315−flippedComparison a b =
316− case compare a b of
317− LT -> GT
318− EQ -> EQ
319− GT -> LT
320−```
321−
322−This is also the most general sort function, allowing you
323−to define any other: `sort == sortWith compare`
324−-}
325−sortWith : (a -> a -> Order) -> [a] -> [a]
326−sortWith = Native.List.sortWith
libraries/Maybe.elmdeleted−61
@@ -1,61 +0,0 @@
1−module Maybe (Maybe(..), maybe, isJust, isNothing, map) where
2−
3−{-| Represents an optional value. Maybe it is there, maybe it is not.
4−
5−# Type and Constructors
6−@docs Maybe
7−
8−# Taking Maybes apart
9−@docs maybe, isJust, isNothing
10−
11−# Map
12−@docs map
13−-}
14−
15−{-| The Maybe datatype. Useful when a computation may or may not
16−result in a value (e.g. logarithm is defined only for positive
17−numbers).
18−-}
19−data Maybe a = Just a | Nothing
20−
21−{-| Provide a default value and a function to extract the contents of a `Maybe`.
22−When given `Nothing` you get the default, when given a `Just` you apply the
23−function to the associated value.
24−
25− isPositive : Maybe Int -> Bool
26− isPositive maybeInt = maybe False (\n -> n > 0) maybeInt
27−-}
28−maybe : b -> (a -> b) -> Maybe a -> b
29−maybe b f m =
30− case m of
31− Just v -> f v
32− Nothing -> b
33−
34−{-| Check if a maybe happens to be a `Just`.
35−
36− isJust (Just 42) == True
37− isJust (Just []) == True
38− isJust Nothing == False
39−-}
40−isJust : Maybe a -> Bool
41−isJust = maybe False (\_ -> True)
42−
43−{-| Check if constructed with `Nothing`.
44−
45− isNothing (Just 42) == False
46− isNothing (Just []) == False
47− isNothing Nothing == True
48−-}
49−isNothing : Maybe a -> Bool
50−isNothing = maybe True (\_ -> False)
51−
52−{-| Transform the contents of a `Maybe` with a given function:
53−
54− map sqrt (Just 9) == Just 3
55− map sqrt Nothing == Nothing
56−-}
57−map : (a -> b) -> Maybe a -> Maybe b
58−map f maybe =
59− case maybe of
60− Just v -> Just (f v)
61− Nothing -> Nothing
libraries/Mouse.elmdeleted−36
@@ -1,36 +0,0 @@
1−
2−module Mouse where
3−
4−{-| Library for working with mouse input.
5−
6−# Position
7−@docs position, x, y
8−
9−# Button Status
10−@docs isDown, clicks
11−
12−-}
13−
14−import Signal (Signal)
15−import Native.Mouse
16−
17−{-| The current mouse position. -}
18−position : Signal (Int,Int)
19−position = Native.Mouse.position
20−
21−{-| The current x-coordinate of the mouse. -}
22−x : Signal Int
23−x = Native.Mouse.x
24−
25−{-| The current y-coordinate of the mouse. -}
26−y : Signal Int
27−y = Native.Mouse.y
28−
29−{-| The current state of the left mouse-button.
30−True when the button is down, and false otherwise. -}
31−isDown : Signal Bool
32−isDown = Native.Mouse.isDown
33−
34−{-| Always equal to unit. Event triggers on every mouse click. -}
35−clicks : Signal ()
36−clicks = Native.Mouse.clicks
libraries/Native/Array.jsdeleted−709
@@ -1,709 +0,0 @@
1−Elm.Native.Array = {};
2−Elm.Native.Array.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Array = elm.Native.Array || {};
5− if (elm.Native.Array.values) return elm.Native.Array.values;
6− if ('values' in Elm.Native.Array)
7− return elm.Native.Array.values = Elm.Native.Array.values;
8−
9− var List = Elm.Native.List.make(elm);
10−
11− // A RRB-Tree has two distinct data types.
12− // Leaf -> "height" is always 0
13− // "table" is an array of elements
14− // Node -> "height" is always greater than 0
15− // "table" is an array of child nodes
16− // "lengths" is an array of accumulated lengths of the child nodes
17−
18− // M is the maximal table size. 32 seems fast. E is the allowed increase
19− // of search steps when concatting to find an index. Lower values will
20− // decrease balancing, but will increase search steps.
21− var M = 32;
22− var E = 2;
23−
24− // An empty array.
25− var empty = { ctor:"_Array", height:0, table:new Array() };
26−
27− function get(i, array) {
28− if (i < 0 || i >= length(array)) {
29− throw new Error("Index " + i + " is out of range. Check the length of " +
30− "your array first or use getMaybe or getWithDefault.");
31− }
32− return unsafeGet(i, array);
33− }
34−
35− function unsafeGet(i, array) {
36− for (var x = array.height; x > 0; x--) {
37− var slot = i >> (x * 5);
38− while (array.lengths[slot] <= i) {
39− slot++;
40− }
41− if (slot > 0) {
42− i -= array.lengths[slot - 1];
43− }
44− array = array.table[slot];
45− }
46− return array.table[i];
47− }
48−
49− // Sets the value at the index i. Only the nodes leading to i will get
50− // copied and updated.
51− function set(i, item, array) {
52− if (i < 0 || length(array) <= i) {
53− return array;
54− }
55− return unsafeSet(i, item, array);
56− }
57−
58− function unsafeSet(i, item, array) {
59− array = nodeCopy(array);
60−
61− if (array.height == 0) {
62− array.table[i] = item;
63− } else {
64− var slot = getSlot(i, array);
65− if (slot > 0) {
66− i -= array.lengths[slot - 1];
67− }
68− array.table[slot] = unsafeSet(i, item, array.table[slot]);
69− }
70− return array;
71− }
72−
73− function initialize(len, f) {
74− if (len == 0) { return empty; }
75− var h = Math.floor(Math.log(len)/Math.log(M));
76− return initialize_(f, h, 0, len);
77− }
78−
79− function initialize_(f, h, from, to) {
80− if (h == 0) {
81− var table = new Array((to - from) % (M + 1));
82− for (var i = 0; i < table.length; i++) {
83− table[i] = f(from + i);
84− }
85− return { ctor:"_Array", height:0, table:table };
86− }
87−
88− var step = Math.pow(M, h);
89− var table = new Array(Math.ceil((to - from) / step));
90− var lengths = new Array(table.length);
91− for (var i = 0; i < table.length; i++) {
92− table[i] = initialize_( f, h - 1, from + (i * step)
93− , Math.min(from + ((i + 1) * step), to));
94− lengths[i] = length(table[i]) + (i > 0 ? lengths[i-1] : 0);
95− }
96− return { ctor:"_Array", height:h, table:table, lengths:lengths };
97− }
98−
99− function fromList(list) {
100− if (list == List.Nil) { return empty; }
101−
102− // Allocate M sized blocks (table) and write list elements to it.
103− var table = new Array(M);
104− var nodes = new Array();
105− var i = 0;
106−
107− while (list.ctor !== '[]') {
108− table[i] = list._0;
109− list = list._1;
110− i++;
111−
112− // table is full, so we can push a leaf containing it into the
113− // next node.
114− if (i == M) {
115− fromListPush({ ctor:"_Array", height:0, table:table }
116− , nodes);
117− table = new Array(M);
118− i = 0;
119− }
120− }
121−
122− // Maybe there is something left on the table.
123− if (i > 0) {
124− fromListPush({ ctor:"_Array", height:0, table:table.splice(0,i) }
125− , nodes);
126− }
127−
128− // Go through all of the nodes and eventually push them into higher nodes.
129− for (var h = 0; h < nodes.length - 1; h++) {
130− if (nodes[h].table.length > 0) {
131− fromListPush(nodes[h], nodes);
132− }
133− }
134−
135− var head = nodes[nodes.length - 1];
136− if (head.height > 0 && head.table.length == 1) {
137− return head.table[0];
138− } else {
139− return head;
140− }
141− }
142−
143− // Push a node into a higher node as a child.
144− function fromListPush(toPush, nodes) {
145− var h = toPush.height;
146−
147− // Maybe the node on this height does not exist.
148− if (nodes.length == h) {
149− nodes.push({ ctor:"_Array", height:h + 1
150− , table:new Array()
151− , lengths:new Array() });
152− }
153−
154− nodes[h].table.push(toPush);
155− var len = length(toPush);
156− if (nodes[h].lengths.length > 0) {
157− len += nodes[h].lengths[nodes[h].lengths.length - 1];
158− }
159− nodes[h].lengths.push(len);
160−
161− if (nodes[h].table.length == M) {
162− fromListPush(nodes[h], nodes);
163− nodes[h] = { ctor:"_Array", height:h + 1
164− , table:new Array()
165− , lengths:new Array() };
166− }
167− }
168−
169− // Pushes an item via push_ to the bottom right of a tree.
170− function push(item, a) {
171− var pushed = push_(item, a);
172− if (pushed !== null) {
173− return pushed;
174− }
175−
176− var newTree = create(item, a.height);
177− return siblise(a, newTree);
178− }
179−
180− // Recursively tries to push an item to the bottom-right most
181− // tree possible. If there is no space left for the item,
182− // null will be returned.
183− function push_(item, a) {
184− // Handle resursion stop at leaf level.
185− if (a.height == 0) {
186− if (a.table.length < M) {
187− var newA = { ctor:"_Array", height:0, table:a.table.slice() };
188− newA.table.push(item);
189− return newA;
190− } else {
191− return null;
192− }
193− }
194−
195− // Recursively push
196− var pushed = push_(item, botRight(a));
197−
198− // There was space in the bottom right tree, so the slot will
199− // be updated.
200− if (pushed != null) {
201− var newA = nodeCopy(a);
202− newA.table[newA.table.length - 1] = pushed;
203− newA.lengths[newA.lengths.length - 1]++;
204− return newA
205− }
206−
207− // When there was no space left, check if there is space left
208− // for a new slot with a tree which contains only the item
209− // at the bottom.
210− if (a.table.length < M) {
211− var newSlot = create(item, a.height - 1);
212− var newA = nodeCopy(a);
213− newA.table.push(newSlot);
214− newA.lengths.push(newA.lengths[newA.lengths.length - 1] + length(newSlot));
215− return newA
216− } else {
217− return null;
218− }
219− }
220−
221− // Converts an array into a list of elements.
222− function toList(a) {
223− return toList_(List.Nil, a);
224− }
225−
226− function toList_(list, a) {
227− for (var i = a.table.length - 1; i >= 0; i--) {
228− list = a.height == 0 ? List.Cons(a.table[i], list) : toList_(list, a.table[i]);
229− }
230− return list;
231− }
232−
233− // Maps a function over the elements of an array.
234− function map(f, a) {
235− var newA = { ctor:"_Array", height:a.height, table:new Array(a.table) };
236− if (a.height > 0) { newA.lengths = a.lengths; }
237− for (var i = 0; i < a.table.length; i++) {
238− newA.table[i] = a.height == 0 ? f(a.table[i]) : map(f, a.table[i]);
239− }
240− return newA;
241− }
242−
243− // Maps a function over the elements with their index as first argument.
244− function indexedMap(f, a) {
245− return indexedMap_(f, a, 0);
246− }
247−
248− function indexedMap_(f, a, from) {
249− var newA = { ctor:"_Array", height:a.height, table:new Array(a.table) };
250− if (a.height > 0) { newA.lengths = a.lengths; }
251− for (var i = 0; i < a.table.length; i++) {
252− newA.table[i] = a.height == 0 ? A2(f, from + i, a.table[i])
253− : indexedMap_( f, a.table[i]
254− , i == 0 ? 0 : a.lengths[i - 1]);
255− }
256− return newA;
257− }
258−
259− function foldl(f, b, a) {
260− if (a.height == 0) {
261− for (var i = 0; i < a.table.length; i++) {
262− b = A2(f, a.table[i], b);
263− }
264− } else {
265− for (var i = 0; i < a.table.length; i++) {
266− b = foldl(f, b, a.table[i]);
267− }
268− }
269− return b;
270− }
271−
272− function foldr(f, b, a) {
273− if (a.height == 0) {
274− for (var i = a.table.length; i--; ) {
275− b = A2(f, a.table[i], b);
276− }
277− } else {
278− for (var i = a.table.length; i--; ) {
279− b = foldl(f, b, a.table[i]);
280− }
281− }
282− return b;
283− }
284−
285− // TODO: currently, it slices the right, then the left. This can be
286− // optimized.
287− function slice(from, to, a) {
288− if (from < 0) { from += length(a); }
289− if (to < 0) { to += length(a); }
290− return sliceLeft(from, sliceRight(to, a));
291− }
292−
293− function sliceRight(to, a) {
294− if (to == length(a)) {
295− return a;
296− }
297−
298− // Handle leaf level.
299− if (a.height == 0) {
300− var newA = { ctor:"_Array", height:0 };
301− newA.table = a.table.slice(0, to);
302− return newA;
303− }
304−
305− // Slice the right recursively.
306− var right = getSlot(to, a);
307− var sliced = sliceRight(to - (right > 0 ? a.lengths[right - 1] : 0), a.table[right]);
308−
309− // Maybe the a node is not even needed, as sliced contains the whole slice.
310− if (right == 0) {
311− return sliced;
312− }
313−
314− // Create new node.
315− var newA = { ctor:"_Array", height:a.height
316− , table:a.table.slice(0, right)
317− , lengths:a.lengths.slice(0, right) };
318− if (sliced.table.length > 0) {
319− newA.table[right] = sliced;
320− newA.lengths[right] = length(sliced) + (right > 0 ? newA.lengths[right - 1] : 0);
321− }
322− return newA;
323− }
324−
325− function sliceLeft(from, a) {
326− if (from == 0) {
327− return a;
328− }
329−
330− // Handle leaf level.
331− if (a.height == 0) {
332− var newA = { ctor:"_Array", height:0 };
333− newA.table = a.table.slice(from, a.table.length + 1);
334− return newA;
335− }
336−
337− // Slice the left recursively.
338− var left = getSlot(from, a);
339− var sliced = sliceLeft(from - (left > 0 ? a.lengths[left - 1] : 0), a.table[left]);
340−
341− // Maybe the a node is not even needed, as sliced contains the whole slice.
342− if (left == a.table.length - 1) {
343− return sliced;
344− }
345−
346− // Create new node.
347− var newA = { ctor:"_Array", height:a.height
348− , table:a.table.slice(left, a.table.length + 1)
349− , lengths:new Array(a.table.length - left) };
350− newA.table[0] = sliced;
351− var len = 0;
352− for (var i = 0; i < newA.table.length; i++) {
353− len += length(newA.table[i]);
354− newA.lengths[i] = len;
355− }
356−
357− return newA;
358− }
359−
360− // Appends two trees.
361− function append(a,b) {
362− if (a.table.length === 0) {
363− return b;
364− }
365− if (b.table.length === 0) {
366− return a;
367− }
368−
369− var c = append_(a, b);
370−
371− // Check if both nodes can be crunshed together.
372− if (c[0].table.length + c[1].table.length <= M) {
373− if (c[0].table.length === 0) {
374− return c[1];
375− }
376− if (c[1].table.length === 0) {
377− return c[0];
378− }
379−
380− // Adjust .table and .lengths
381− c[0].table = c[0].table.concat(c[1].table);
382− if (c[0].height > 0) {
383− var len = length(c[0]);
384− for (var i = 0; i < c[1].lengths.length; i++) {
385− c[1].lengths[i] += len;
386− }
387− c[0].lengths = c[0].lengths.concat(c[1].lengths);
388− }
389−
390− return c[0];
391− }
392−
393− var toRemove = calcToRemove(a, b);
394− if (toRemove > E) {
395− c = shuffle(c[0], c[1], toRemove);
396− }
397−
398− return siblise(c[0], c[1]);
399− }
400−
401− // Returns an array of two nodes; right and left. One node _may_ be empty.
402− function append_(a, b) {
403− if (a.height === 0 && b.height === 0) {
404− return [a, b];
405− }
406−
407− if (a.height !== 1 || b.height !== 1) {
408− if (a.height === b.height) {
409− a = nodeCopy(a);
410− b = nodeCopy(b);
411− var appended = append_(botRight(a), botLeft(b));
412−
413− insertRight(a, appended[1]);
414− insertLeft(b, appended[0]);
415− } else if (a.height > b.height) {
416− a = nodeCopy(a);
417− var appended = append_(botRight(a), b);
418−
419− insertRight(a, appended[0]);
420− b = parentise(appended[1], appended[1].height + 1);
421− } else {
422− b = nodeCopy(b);
423− var appended = append_(a, botLeft(b));
424−
425− var left = appended[0].table.length === 0 ? 0 : 1;
426− var right = left === 0 ? 1 : 0;
427− insertLeft(b, appended[left]);
428− a = parentise(appended[right], appended[right].height + 1);
429− }
430− }
431−
432− // Check if balancing is needed and return based on that.
433− if (a.table.length === 0 || b.table.length === 0) {
434− return [a,b];
435− }
436−
437− var toRemove = calcToRemove(a, b);
438− if (toRemove <= E) {
439− return [a,b];
440− }
441− return shuffle(a, b, toRemove);
442− }
443−
444− // Helperfunctions for append_. Replaces a child node at the side of the parent.
445− function insertRight(parent, node) {
446− var index = parent.table.length - 1;
447− parent.table[index] = node;
448− parent.lengths[index] = length(node)
449− parent.lengths[index] += index > 0 ? parent.lengths[index - 1] : 0;
450− }
451−
452− function insertLeft(parent, node) {
453− if (node.table.length > 0) {
454− parent.table[0] = node;
455− parent.lengths[0] = length(node);
456−
457− var len = length(parent.table[0]);
458− for (var i = 1; i < parent.lengths.length; i++) {
459− len += length(parent.table[i]);
460− parent.lengths[i] = len;
461− }
462− } else {
463− parent.table.shift();
464− for (var i = 1; i < parent.lengths.length; i++) {
465− parent.lengths[i] = parent.lengths[i] - parent.lengths[0];
466− }
467− parent.lengths.shift();
468− }
469− }
470−
471− // Returns the extra search steps for E. Refer to the paper.
472− function calcToRemove(a, b) {
473− var subLengths = 0;
474− for (var i = 0; i < a.table.length; i++) {
475− subLengths += a.table[i].table.length;
476− }
477− for (var i = 0; i < b.table.length; i++) {
478− subLengths += b.table[i].table.length;
479− }
480−
481− var toRemove = a.table.length + b.table.length
482− return toRemove - (Math.floor((subLengths - 1) / M) + 1);
483− }
484−
485− // get2, set2 and saveSlot are helpers for accessing elements over two arrays.
486− function get2(a, b, index) {
487− return index < a.length ? a[index] : b[index - a.length];
488− }
489−
490− function set2(a, b, index, value) {
491− if (index < a.length) {
492− a[index] = value;
493− } else {
494− b[index - a.length] = value;
495− }
496− }
497−
498− function saveSlot(a, b, index, slot) {
499− set2(a.table, b.table, index, slot);
500−
501− var l = (index == 0 || index == a.lengths.length) ?
502− 0 : get2(a.lengths, a.lengths, index - 1);
503− set2(a.lengths, b.lengths, index, l + length(slot));
504− }
505−
506− // Creates a node or leaf with a given length at their arrays for perfomance.
507− // Is only used by shuffle.
508− function createNode(h, length) {
509− if (length < 0) { length = 0; }
510− var a = { ctor:"_Array", height:h, table:new Array(length) };
511− if (h > 0) {
512− a.lengths = new Array(length);
513− }
514− return a;
515− }
516−
517− // Returns an array of two balanced nodes.
518− function shuffle(a, b, toRemove) {
519− var newA = createNode(a.height, Math.min(M, a.table.length + b.table.length - toRemove));
520− var newB = createNode(a.height, newA.table.length - (a.table.length + b.table.length - toRemove));
521−
522− // Skip the slots with size M. More precise: copy the slot references
523− // to the new node
524− var read = 0;
525− while (get2(a.table, b.table, read).table.length % M == 0) {
526− set2(newA.table, newB.table, read, get2(a.table, b.table, read));
527− set2(newA.lengths, newB.lengths, read, get2(a.lengths, b.lengths, read));
528− read++;
529− }
530−
531− // Pulling items from left to right, caching in a slot before writing
532− // it into the new nodes.
533− var write = read;
534− var slot = new createNode(a.height - 1, 0);
535− var from = 0;
536−
537− // If the current slot is still containing data, then there will be at
538− // least one more write, so we do not break this loop yet.
539− while (read - write - (slot.table.length > 0 ? 1 : 0) < toRemove) {
540− // Find out the max possible items for copying.
541− var source = get2(a.table, b.table, read);
542− var to = Math.min(M - slot.table.length, source.table.length)
543−
544− // Copy and adjust size table.
545− slot.table = slot.table.concat(source.table.slice(from, to));
546− if (slot.height > 0) {
547− var len = slot.lengths.length;
548− for (var i = len; i < len + to - from; i++) {
549− slot.lengths[i] = length(slot.table[i]);
550− slot.lengths[i] += (i > 0 ? slot.lengths[i - 1] : 0);
551− }
552− }
553−
554− from += to;
555−
556− // Only proceed to next slots[i] if the current one was
557− // fully copied.
558− if (source.table.length <= to) {
559− read++; from = 0;
560− }
561−
562− // Only create a new slot if the current one is filled up.
563− if (slot.table.length == M) {
564− saveSlot(newA, newB, write, slot);
565− slot = createNode(a.height - 1,0);
566− write++;
567− }
568− }
569−
570− // Cleanup after the loop. Copy the last slot into the new nodes.
571− if (slot.table.length > 0) {
572− saveSlot(newA, newB, write, slot);
573− write++;
574− }
575−
576− // Shift the untouched slots to the left
577− while (read < a.table.length + b.table.length ) {
578− saveSlot(newA, newB, write, get2(a.table, b.table, read));
579− read++; write++;
580− }
581−
582− return [newA, newB];
583− }
584−
585− // Navigation functions
586− function botRight(a) { return a.table[a.table.length - 1]; }
587− function botLeft(a) { return a.table[0]; }
588−
589− // Copies a node for updating. Note that you should not use this if
590− // only updating only one of "table" or "lengths" for performance reasons.
591− function nodeCopy(a) {
592− var newA = { ctor:"_Array", height:a.height
593− , table:a.table.slice() };
594− if (a.height > 0) { newA.lengths = a.lengths.slice(); }
595− return newA;
596− }
597−
598− // Returns how many items are in the tree.
599− function length(array) {
600− if (array.height == 0) {
601− return array.table.length;
602− } else {
603− return array.lengths[array.lengths.length - 1];
604− }
605− }
606−
607− // Calculates in which slot of "table" the item probably is, then
608− // find the exact slot via forward searching in "lengths". Returns the index.
609− function getSlot(i, a) {
610− var slot = i >> (5 * a.height);
611− while (a.lengths[slot] <= i) {
612− slot++;
613− }
614− return slot;
615− }
616−
617− // Recursively creates a tree with a given height containing
618− // only the given item.
619− function create(item, h) {
620− if (h == 0) {
621− return { ctor:"_Array", height:0
622− , table:[item] };
623− } else {
624− return { ctor:"_Array", height:h
625− , table:[create(item, h - 1)]
626− , lengths:[1] };
627− }
628− }
629−
630− // Recursively creates a tree that contains the given tree.
631− function parentise(tree, h) {
632− if (h == tree.height) {
633− return tree;
634− } else {
635− return { ctor:"_Array", height:h
636− , table:[parentise(tree, h - 1)]
637− , lengths:[length(tree)] };
638− }
639− }
640−
641− // Emphasizes blood brotherhood beneath two trees.
642− function siblise(a, b) {
643− return { ctor:"_Array", height:a.height + 1
644− , table:[a, b]
645− , lengths:[length(a), length(a) + length(b)] };
646− }
647−
648− function toJSArray(a) {
649− var jsArray = new Array(length(a));
650− toJSArray_(jsArray, 0, a);
651− return jsArray;
652− }
653−
654− function toJSArray_(jsArray, i, a) {
655− for (var t = 0; t < a.table.length; t++) {
656− if (a.height == 0) {
657− jsArray[i + t] = a.table[t];
658− } else {
659− var inc = t == 0 ? 0 : a.lengths[t - 1];
660− toJSArray_(jsArray, i + inc, a.table[t]);
661− }
662− }
663− }
664−
665− function fromJSArray(jsArray) {
666− if (jsArray.length == 0) { return empty; }
667− var h = Math.floor(Math.log(jsArray.length) / Math.log(M));
668− return fromJSArray_(jsArray, h, 0, jsArray.length);
669− }
670−
671− function fromJSArray_(jsArray, h, from, to) {
672− if (h == 0) {
673− return { ctor:"_Array", height:0
674− , table:jsArray.slice(from, to) };
675− }
676−
677− var step = Math.pow(M, h);
678− var table = new Array(Math.ceil((to - from) / step));
679− var lengths = new Array(table.length);
680− for (var i = 0; i < table.length; i++) {
681− table[i] = fromJSArray_( jsArray, h - 1, from + (i * step)
682− , Math.min(from + ((i + 1) * step), to));
683− lengths[i] = length(table[i]) + (i > 0 ? lengths[i-1] : 0);
684− }
685− return { ctor:"_Array", height:h, table:table, lengths:lengths };
686− }
687−
688− Elm.Native.Array.values = {
689− empty:empty,
690− fromList:fromList,
691− toList:toList,
692− initialize:F2(initialize),
693− append:F2(append),
694− push:F2(push),
695− slice:F3(slice),
696− get:F2(get),
697− set:F3(set),
698− map:F2(map),
699− indexedMap:F2(indexedMap),
700− foldl:F3(foldl),
701− foldr:F3(foldr),
702− length:length,
703−
704− toJSArray:toJSArray,
705− fromJSArray:fromJSArray
706− };
707−
708− return elm.Native.Array.values = Elm.Native.Array.values;
709−}
libraries/Native/Basics.jsdeleted−111
@@ -1,111 +0,0 @@
1−
2−Elm.Native.Basics = {};
3−Elm.Native.Basics.make = function(elm) {
4− elm.Native = elm.Native || {};
5− elm.Native.Basics = elm.Native.Basics || {};
6− if (elm.Native.Basics.values) return elm.Native.Basics.values;
7−
8− var JS = Elm.Native.JavaScript.make(elm);
9− var Utils = Elm.Native.Utils.make(elm);
10−
11− function div(a, b) {
12− return (a/b)|0;
13− }
14− function rem(a, b) {
15− return a % b;
16− }
17− var mod = Utils.mod;
18− function logBase(base, n) {
19− return Math.log(n) / Math.log(base);
20− }
21− function negate(n) {
22− return -n;
23− }
24− function abs(n) {
25− return n < 0 ? -n : n;
26− }
27−
28− function min(a, b) {
29− return Utils.cmp(a,b) < 0 ? a : b;
30− }
31− function max(a, b) {
32− return Utils.cmp(a,b) > 0 ? a : b;
33− }
34− function clamp(lo, hi, n) {
35− return Utils.cmp(n,lo) < 0 ? lo : Utils.cmp(n,hi) > 0 ? hi : n;
36− }
37−
38− function xor(a, b) {
39− return a !== b;
40− }
41− function not(b) {
42− return !b;
43− }
44− function isInfinite(n) {
45− return n === Infinity || n === -Infinity
46− }
47−
48− function truncate(n) {
49− return n|0;
50− }
51−
52− function degrees(d) {
53− return d * Math.PI / 180;
54− }
55− function turns(t) {
56− return 2 * Math.PI * t;
57− }
58− function fromPolar(point) {
59− var r = point._0;
60− var t = point._1;
61− return Utils.Tuple2(r * Math.cos(t), r * Math.sin(t));
62− }
63− function toPolar(point) {
64− var x = point._0;
65− var y = point._1;
66− return Utils.Tuple2(Math.sqrt(x * x + y * y), Math.atan2(y,x));
67− }
68−
69− var basics = {
70− div: F2(div),
71− rem: F2(rem),
72− mod: mod,
73−
74− pi: Math.PI,
75− e: Math.E,
76− cos: Math.cos,
77− sin: Math.sin,
78− tan: Math.tan,
79− acos: Math.acos,
80− asin: Math.asin,
81− atan: Math.atan,
82− atan2: F2(Math.atan2),
83−
84− degrees: degrees,
85− turns: turns,
86− fromPolar: fromPolar,
87− toPolar: toPolar,
88−
89− sqrt: Math.sqrt,
90− logBase: F2(logBase),
91− negate: negate,
92− abs: abs,
93− min: F2(min),
94− max: F2(max),
95− clamp: F3(clamp),
96− compare: Utils.compare,
97−
98− xor: F2(xor),
99− not: not,
100−
101− truncate: truncate,
102− ceiling: Math.ceil,
103− floor: Math.floor,
104− round: Math.round,
105− toFloat: function(x) { return x; },
106− isNaN: isNaN,
107− isInfinite: isInfinite
108− };
109−
110− return elm.Native.Basics.values = basics;
111−};
libraries/Native/Bitwise.jsdeleted−25
@@ -1,25 +0,0 @@
1−Elm.Native.Bitwise = {};
2−Elm.Native.Bitwise.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Bitwise = elm.Native.Bitwise || {};
5− if (elm.Native.Bitwise.values) return elm.Native.Bitwise.values;
6−
7− function and(a,b) { return a & b; }
8− function or (a,b) { return a | b; }
9− function xor(a,b) { return a ^ b; }
10− function not(a) { return ~a; }
11− function sll(a,offset) { return a << offset; }
12− function sra(a,offset) { return a >> offset; }
13− function srl(a,offset) { return a >>> offset; }
14−
15− return elm.Native.Bitwise.values = {
16− and: F2(and),
17− or : F2(or ),
18− xor: F2(xor),
19− complement: not,
20− shiftLeft : F2(sll),
21− shiftRightArithmatic: F2(sra),
22− shiftRightLogical : F2(srl)
23− };
24−
25−};
libraries/Native/Char.jsdeleted−31
@@ -1,31 +0,0 @@
1−Elm.Native.Char = {};
2−Elm.Native.Char.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Char = elm.Native.Char || {};
5− if (elm.Native.Char.values) return elm.Native.Char.values;
6−
7− var Utils = Elm.Native.Utils.make(elm);
8−
9− function isBetween(lo,hi) { return function(chr) {
10− var c = chr.charCodeAt(0);
11− return lo <= c && c <= hi;
12− };
13− }
14− var isDigit = isBetween('0'.charCodeAt(0),'9'.charCodeAt(0));
15− var chk1 = isBetween('a'.charCodeAt(0),'f'.charCodeAt(0));
16− var chk2 = isBetween('A'.charCodeAt(0),'F'.charCodeAt(0));
17−
18− return elm.Native.Char.values = {
19− fromCode : function(c) { return String.fromCharCode(c); },
20− toCode : function(c) { return c.toUpperCase().charCodeAt(0); },
21− toUpper : function(c) { return Utils.chr(c.toUpperCase()); },
22− toLower : function(c) { return Utils.chr(c.toLowerCase()); },
23− toLocaleUpper : function(c) { return Utils.chr(c.toLocaleUpperCase()); },
24− toLocaleLower : function(c) { return Utils.chr(c.toLocaleLowerCase()); },
25− isLower : isBetween('a'.charCodeAt(0),'z'.charCodeAt(0)),
26− isUpper : isBetween('A'.charCodeAt(0),'Z'.charCodeAt(0)),
27− isDigit : isDigit,
28− isOctDigit : isBetween('0'.charCodeAt(0),'7'.charCodeAt(0)),
29− isHexDigit : function(c) { return isDigit(c) || chk1(c) || chk2(c); }
30− };
31−};
libraries/Native/Color.jsdeleted−32
@@ -1,32 +0,0 @@
1−Elm.Native.Color = {};
2−Elm.Native.Color.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Color = elm.Native.Color || {};
5− if (elm.Native.Color.values) return elm.Native.Color.values;
6−
7− var Utils = Elm.Native.Utils.make(elm);
8−
9− function toCss(c) {
10− var format = '';
11− var colors = '';
12− if (c.ctor === 'RGBA') {
13− format = 'rgb';
14− colors = c._0 + ', ' + c._1 + ', ' + c._2;
15− } else {
16− format = 'hsl';
17− colors = (c._0 * 180 / Math.PI) + ', ' +
18− (c._1 * 100) + '%, ' +
19− (c._2 * 100) + '%';
20− }
21− if (c._3 === 1) {
22− return format + '(' + colors + ')';
23− } else {
24− return format + 'a(' + colors + ', ' + c._3 + ')';
25− }
26− }
27−
28− return elm.Native.Color.values = {
29− toCss:toCss
30− };
31−
32−};
libraries/Native/Date.jsdeleted−33
@@ -1,33 +0,0 @@
1−Elm.Native.Date = {};
2−Elm.Native.Date.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Date = elm.Native.Date || {};
5− if (elm.Native.Date.values) return elm.Native.Date.values;
6−
7− var Maybe = Elm.Maybe.make(elm);
8−
9− function dateNow() { return new window.Date; }
10− function readDate(str) {
11− var d = new window.Date(str);
12− if (isNaN(d.getTime())) return Maybe.Nothing;
13− return Maybe.Just(d);
14− }
15−
16− var dayTable = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
17− var monthTable = ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
18− "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
19−
20− return elm.Native.Date.values = {
21− read : readDate,
22− year : function(d) { return d.getFullYear(); },
23− month : function(d) { return { ctor:monthTable[d.getMonth()] }; },
24− day : function(d) { return d.getDate(); },
25− hour : function(d) { return d.getHours(); },
26− minute : function(d) { return d.getMinutes(); },
27− second : function(d) { return d.getSeconds(); },
28− toTime : function(d) { return d.getTime(); },
29− fromTime: function(t) { return new window.Date(t); },
30− dayOfWeek : function(d) { return { ctor:dayTable[d.getDay()] }; }
31− };
32−
33−};
libraries/Native/Debug.jsdeleted−60
@@ -1,60 +0,0 @@
1−Elm.Native.Debug = {};
2−Elm.Native.Debug.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Debug = elm.Native.Debug || {};
5− if (elm.Native.Debug.values) return elm.Native.Debug.values;
6− if ('values' in Elm.Native.Debug)
7− return elm.Native.Debug.values = Elm.Native.Debug.values;
8−
9− var show = Elm.Native.Show.make(elm).show;
10− var replace = Elm.Native.Utils.make(elm).replace;
11−
12− function log(tag, value) {
13− var msg = tag + ': ' + show(value);
14− var process = process || {};
15− if (process.stdout) {
16− process.stdout.write(msg);
17− } else {
18− console.log(msg);
19− }
20− return value;
21− }
22−
23− function tracePath(debugId, form) {
24− return replace([["debugTracePathId",debugId]], form);
25− }
26−
27− function WatchTracker() {
28− this.frames = [{}];
29− this.clear = function() {
30− this.watches = {};
31− };
32− this.pushFrame = function() {
33− var lastFrame = this.frames[this.frames.length - 1];
34− this.frames.push(lastFrame);
35− }
36− this.notify = function(tag, value) {
37− this.frames[this.frames.length - 1][tag] = value;
38− };
39− }
40− var watchTracker = new WatchTracker();
41−
42− function watch(tag, value) {
43− watchTracker.notify(tag, value);
44− return value;
45− }
46−
47− function watchSummary(tag, f, value) {
48− watchTracker.notify(tag, f(value));
49− return value;
50− }
51−
52− Elm.Native.Debug.values = {
53− tracePath: F2(tracePath),
54− log: F2(log),
55− watch: F2(watch),
56− watchSummary:F3(watchSummary),
57− watchTracker: watchTracker
58− };
59− return elm.Native.Debug.values = Elm.Native.Debug.values;
60−};
libraries/Native/Error.jsdeleted−30
@@ -1,30 +0,0 @@
1−Elm.Native.Error = {};
2−Elm.Native.Error.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Error = elm.Native.Error || {};
5− if (elm.Native.Error.values) return elm.Native.Error.values;
6−
7− function indent(lines) {
8− var msg = '';
9− for (var i = 0; i < lines.length; ++i) {
10− msg += '<br/>&nbsp; &nbsp; ' + lines[i];
11− }
12− return msg;
13− }
14−
15− function Case(moduleName, span) {
16− var msg = indent(['Non-exhaustive pattern match in case-expression.',
17− 'Make sure your patterns cover every case!']);
18− throw new Error('Runtime error in module ' + moduleName + ' (' + span + '):' + msg);
19− }
20−
21− function If(moduleName, span) {
22− var msg = indent(['Non-exhaustive pattern match in multi-way-if expression.',
23− 'It is best to use \'otherwise\' as the last branch of multi-way-if.']);
24− throw new Error('Runtime error in module ' + moduleName + ' (' + span + '):' + msg);
25− }
26−
27− function raise(str) { throw new Error(str); }
28−
29− return elm.Native.Error.values = { Case: Case, If: If, raise: raise };
30−};
libraries/Native/Function.jsdeleted−101
@@ -1,101 +0,0 @@
1−
2−function F2(fun) {
3− function wrapper(a) { return function(b) { return fun(a,b) } }
4− wrapper.arity = 2;
5− wrapper.func = fun;
6− return wrapper;
7−}
8−
9−function F3(fun) {
10− function wrapper(a) {
11− return function(b) { return function(c) { return fun(a,b,c) }}
12− }
13− wrapper.arity = 3;
14− wrapper.func = fun;
15− return wrapper;
16−}
17−
18−function F4(fun) {
19− function wrapper(a) { return function(b) { return function(c) {
20− return function(d) { return fun(a,b,c,d) }}}
21− }
22− wrapper.arity = 4;
23− wrapper.func = fun;
24− return wrapper;
25−}
26−
27−function F5(fun) {
28− function wrapper(a) { return function(b) { return function(c) {
29− return function(d) { return function(e) { return fun(a,b,c,d,e) }}}}
30− }
31− wrapper.arity = 5;
32− wrapper.func = fun;
33− return wrapper;
34−}
35−
36−function F6(fun) {
37− function wrapper(a) { return function(b) { return function(c) {
38− return function(d) { return function(e) { return function(f) {
39− return fun(a,b,c,d,e,f) }}}}}
40− }
41− wrapper.arity = 6;
42− wrapper.func = fun;
43− return wrapper;
44−}
45−
46−function F7(fun) {
47− function wrapper(a) { return function(b) { return function(c) {
48− return function(d) { return function(e) { return function(f) {
49− return function(g) { return fun(a,b,c,d,e,f,g) }}}}}}
50− }
51− wrapper.arity = 7;
52− wrapper.func = fun;
53− return wrapper;
54−}
55−
56−function F8(fun) {
57− function wrapper(a) { return function(b) { return function(c) {
58− return function(d) { return function(e) { return function(f) {
59− return function(g) { return function(h) {return fun(a,b,c,d,e,f,g,h)}}}}}}}
60− }
61− wrapper.arity = 8;
62− wrapper.func = fun;
63− return wrapper;
64−}
65−
66−function F9(fun) {
67− function wrapper(a) { return function(b) { return function(c) {
68− return function(d) { return function(e) { return function(f) {
69− return function(g) { return function(h) { return function(i) {
70− return fun(a,b,c,d,e,f,g,h,i) }}}}}}}}
71− }
72− wrapper.arity = 9;
73− wrapper.func = fun;
74− return wrapper;
75−}
76−
77−function A2(fun,a,b) {
78− return fun.arity === 2 ? fun.func(a,b) : fun(a)(b);
79−}
80−function A3(fun,a,b,c) {
81− return fun.arity === 3 ? fun.func(a,b,c) : fun(a)(b)(c);
82−}
83−function A4(fun,a,b,c,d) {
84− return fun.arity === 4 ? fun.func(a,b,c,d) : fun(a)(b)(c)(d);
85−}
86−function A5(fun,a,b,c,d,e) {
87− return fun.arity === 5 ? fun.func(a,b,c,d,e) : fun(a)(b)(c)(d)(e);
88−}
89−function A6(fun,a,b,c,d,e,f) {
90− return fun.arity === 6 ? fun.func(a,b,c,d,e,f) : fun(a)(b)(c)(d)(e)(f);
91−}
92−function A7(fun,a,b,c,d,e,f,g) {
93− return fun.arity === 7 ? fun.func(a,b,c,d,e,f,g) : fun(a)(b)(c)(d)(e)(f)(g);
94−}
95−function A8(fun,a,b,c,d,e,f,g,h) {
96− return fun.arity === 8 ? fun.func(a,b,c,d,e,f,g,h) : fun(a)(b)(c)(d)(e)(f)(g)(h);
97−}
98−function A9(fun,a,b,c,d,e,f,g,h,i) {
99− return fun.arity === 9 ? fun.func(a,b,c,d,e,f,g,h,i)
100− : fun(a)(b)(c)(d)(e)(f)(g)(h)(i);
101−}
libraries/Native/Graphics/Collage.jsdeleted−23
@@ -1,23 +0,0 @@
1−Elm.Native.Graphics.Collage = {};
2−Elm.Native.Graphics.Collage.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Graphics = elm.Native.Graphics || {};
6− elm.Native.Graphics.Collage = elm.Native.Graphics.Collage || {};
7− if (elm.Native.Graphics.Collage.values) return elm.Native.Graphics.Collage.values;
8−
9− var newElement = Elm.Graphics.Element.make(elm).newElement;
10− var C = ElmRuntime.use(ElmRuntime.Render.Collage);
11−
12− function collage(w,h,forms) {
13− return A3(newElement, w, h, {
14− ctor: 'Custom',
15− type: 'Collage',
16− render: C.render,
17− update: C.update,
18− model: {w:w, h:h, forms:forms}
19− });
20− }
21− return elm.Native.Graphics.Collage.values = { collage:F3(collage) };
22−
23−};
libraries/Native/Graphics/Input.jsdeleted−410
@@ -1,410 +0,0 @@
1−Elm.Native.Graphics.Input = {};
2−Elm.Native.Graphics.Input.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Graphics = elm.Native.Graphics || {};
5− elm.Native.Graphics.Input = elm.Native.Graphics.Input || {};
6− if (elm.Native.Graphics.Input.values) return elm.Native.Graphics.Input.values;
7−
8− var Render = ElmRuntime.use(ElmRuntime.Render.Element);
9− var newNode = ElmRuntime.use(ElmRuntime.Render.Utils).newElement;
10−
11− var toCss = Elm.Native.Color.make(elm).toCss;
12− var Text = Elm.Native.Text.make(elm);
13− var Signal = Elm.Signal.make(elm);
14− var newElement = Elm.Graphics.Element.make(elm).newElement;
15− var List = Elm.Native.List.make(elm);
16− var Utils = Elm.Native.Utils.make(elm);
17− var Tuple2 = Utils.Tuple2;
18−
19− function input(initialValue) {
20− var signal = Signal.constant(initialValue);
21− return { _:{}, signal:signal, handle:signal };
22− }
23−
24− function renderDropDown(model) {
25− var drop = newNode('select');
26− drop.style.border = '0 solid';
27− drop.style.pointerEvents = 'auto';
28− drop.style.display = 'block';
29−
30− drop.elm_signal = model.signal;
31− drop.elm_values = List.toArray(model.values);
32− var values = drop.elm_values;
33−
34− for (var i = 0; i < values.length; ++i) {
35− var option = newNode('option');
36− var name = values[i]._0;
37− option.value = name;
38− option.innerHTML = name;
39− drop.appendChild(option);
40− }
41− drop.addEventListener('change', function() {
42− elm.notify(drop.elm_signal.id, drop.elm_values[drop.selectedIndex]._1);
43− });
44−
45− return drop;
46− }
47−
48− function updateDropDown(node, oldModel, newModel) {
49− node.elm_signal = newModel.signal;
50− node.elm_values = List.toArray(newModel.values);
51−
52− var values = node.elm_values;
53− var kids = node.childNodes;
54− var kidsLength = kids.length;
55−
56− var i = 0;
57− for (; i < kidsLength && i < values.length; ++i) {
58− var option = kids[i];
59− var name = values[i]._0;
60− option.value = name;
61− option.innerHTML = name;
62− }
63− for (; i < kidsLength; ++i) {
64− node.removeChild(node.lastChild);
65− }
66− for (; i < values.length; ++i) {
67− var option = newNode('option');
68− var name = values[i]._0;
69− option.value = name;
70− option.innerHTML = name;
71− node.appendChild(option);
72− }
73− }
74−
75− function dropDown(signal, values) {
76− return A3(newElement, 100, 24, {
77− ctor: 'Custom',
78− type: 'DropDown',
79− render: renderDropDown,
80− update: updateDropDown,
81− model: {
82− signal: signal,
83− values: values
84− }
85− });
86− }
87−
88− function renderButton(model) {
89− var node = newNode('button');
90− node.style.display = 'block';
91− node.style.pointerEvents = 'auto';
92− node.elm_signal = model.signal;
93− node.elm_value = model.value;
94− function click() {
95− elm.notify(node.elm_signal.id, node.elm_value);
96− }
97− node.addEventListener('click', click);
98− node.innerHTML = model.text;
99− return node;
100− }
101−
102− function updateButton(node, oldModel, newModel) {
103− node.elm_signal = newModel.signal;
104− node.elm_value = newModel.value;
105− var txt = newModel.text;
106− if (oldModel.text !== txt) node.innerHTML = txt;
107− }
108−
109− function button(signal, value, text) {
110− return A3(newElement, 100, 40, {
111− ctor: 'Custom',
112− type: 'Button',
113− render: renderButton,
114− update: updateButton,
115− model: { signal:signal, value:value, text:text }
116− });
117− }
118−
119− function renderCustomButton(model) {
120− var btn = newNode('div');
121− btn.style.pointerEvents = 'auto';
122− btn.elm_signal = model.signal;
123− btn.elm_value = model.value;
124−
125− btn.elm_up = Render.render(model.up);
126− btn.elm_hover = Render.render(model.hover);
127− btn.elm_down = Render.render(model.down);
128−
129− btn.elm_up.style.display = 'block';
130− btn.elm_hover.style.display = 'none';
131− btn.elm_down.style.display = 'none';
132−
133− btn.appendChild(btn.elm_up);
134− btn.appendChild(btn.elm_hover);
135− btn.appendChild(btn.elm_down);
136−
137− function swap(visibleNode, hiddenNode1, hiddenNode2) {
138− visibleNode.style.display = 'block';
139− hiddenNode1.style.display = 'none';
140− hiddenNode2.style.display = 'none';
141− }
142−
143− var overCount = 0;
144− function over(e) {
145− if (overCount++ > 0) return;
146− swap(btn.elm_hover, btn.elm_down, btn.elm_up);
147− }
148− function out(e) {
149− if (btn.contains(e.toElement || e.relatedTarget)) return;
150− overCount = 0;
151− swap(btn.elm_up, btn.elm_down, btn.elm_hover);
152− }
153− function up() {
154− swap(btn.elm_hover, btn.elm_down, btn.elm_up);
155− elm.notify(btn.elm_signal.id, btn.elm_value);
156− }
157− function down() {
158− swap(btn.elm_down, btn.elm_hover, btn.elm_up);
159− }
160−
161− btn.addEventListener('mouseover', over);
162− btn.addEventListener('mouseout' , out);
163− btn.addEventListener('mousedown', down);
164− btn.addEventListener('mouseup' , up);
165−
166− return btn;
167− }
168−
169− function updateCustomButton(node, oldModel, newModel) {
170− node.elm_signal = newModel.signal;
171− node.elm_value = newModel.value;
172−
173− var kids = node.childNodes;
174− var styleUp = kids[0].style.display;
175− var styleHover = kids[1].style.display;
176− var styleDown = kids[2].style.display;
177−
178− Render.update(kids[0], oldModel.up, newModel.up);
179− Render.update(kids[1], oldModel.hover, newModel.hover);
180− Render.update(kids[2], oldModel.down, newModel.down);
181−
182− var kids = node.childNodes;
183− kids[0].style.display = styleUp;
184− kids[1].style.display = styleHover;
185− kids[2].style.display = styleDown;
186− }
187−
188− function max3(a,b,c) {
189− var ab = a > b ? a : b;
190− return ab > c ? ab : c;
191− }
192−
193− function customButton(signal, value, up, hover, down) {
194− return A3(newElement,
195− max3(up.props.width, hover.props.width, down.props.width),
196− max3(up.props.height, hover.props.height, down.props.height),
197− { ctor: 'Custom',
198− type: 'CustomButton',
199− render: renderCustomButton,
200− update: updateCustomButton,
201− model: { signal:signal, value:value, up:up, hover:hover, down:down }
202− });
203− }
204−
205− function renderCheckbox(model) {
206− var node = newNode('input');
207− node.type = 'checkbox';
208− node.checked = model.checked;
209− node.style.display = 'block';
210− node.style.pointerEvents = 'auto';
211− node.elm_signal = model.signal;
212− node.elm_handler = model.handler;
213− function change() {
214− elm.notify(node.elm_signal.id, node.elm_handler(node.checked));
215− }
216− node.addEventListener('change', change);
217− return node;
218− }
219−
220− function updateCheckbox(node, oldModel, newModel) {
221− node.elm_signal = newModel.signal;
222− node.elm_handler = newModel.handler;
223− node.checked = newModel.checked;
224− return true;
225− }
226−
227− function checkbox(signal, handler, checked) {
228− return A3(newElement, 13, 13, {
229− ctor: 'Custom',
230− type: 'CheckBox',
231− render: renderCheckbox,
232− update: updateCheckbox,
233− model: { signal:signal, handler:handler, checked:checked }
234− });
235− }
236−
237− function setRange(node, start, end, dir) {
238− if (node.parentNode) {
239− node.setSelectionRange(start, end, dir);
240− } else {
241− setTimeout(function(){node.setSelectionRange(start, end, dir);}, 0);
242− }
243− }
244−
245− function updateIfNeeded(css, attribute, latestAttribute) {
246− if (css[attribute] !== latestAttribute) {
247− css[attribute] = latestAttribute;
248− }
249− }
250− function cssDimensions(dimensions) {
251− return dimensions.top + 'px ' +
252− dimensions.right + 'px ' +
253− dimensions.bottom + 'px ' +
254− dimensions.left + 'px';
255− }
256− function updateFieldStyle(css, style) {
257− updateIfNeeded(css, 'padding', cssDimensions(style.padding));
258−
259− var outline = style.outline;
260− updateIfNeeded(css, 'border-width', cssDimensions(outline.width));
261− updateIfNeeded(css, 'border-color', toCss(outline.color));
262− updateIfNeeded(css, 'border-radius', outline.radius + 'px');
263−
264− var highlight = style.highlight;
265− if (highlight.width === 0) {
266− css.outline = 'none';
267− } else {
268− updateIfNeeded(css, 'outline-width', highlight.width + 'px');
269− updateIfNeeded(css, 'outline-color', toCss(highlight.color));
270− }
271−
272− var textStyle = style.style;
273− updateIfNeeded(css, 'color', toCss(textStyle.color));
274− if (textStyle.typeface.ctor !== '[]') {
275− updateIfNeeded(css, 'font-family', Text.toTypefaces(textStyle.typeface));
276− }
277− if (textStyle.height.ctor !== "Nothing") {
278− updateIfNeeded(css, 'font-size', textStyle.height._0 + 'px');
279− }
280− updateIfNeeded(css, 'font-weight', textStyle.bold ? 'bold' : 'normal');
281− updateIfNeeded(css, 'font-style', textStyle.italic ? 'italic' : 'normal');
282− if (textStyle.line.ctor !== 'Nothing') {
283− updateIfNeeded(css, 'text-decoration', Text.toLine(textStyle.line._0));
284− }
285− }
286−
287− function renderField(model) {
288− var field = newNode('input');
289− updateFieldStyle(field.style, model.style);
290− field.style.borderStyle = 'solid';
291− field.style.pointerEvents = 'auto';
292−
293− field.type = model.type;
294− field.placeholder = model.placeHolder;
295− field.value = model.content.string;
296−
297− field.elm_signal = model.signal;
298− field.elm_handler = model.handler;
299− field.elm_old_value = field.value;
300−
301− function inputUpdate(event) {
302− var curr = field.elm_old_value;
303− var next = field.value;
304− if (curr === next) {
305− return;
306− }
307−
308− var direction = field.selectionDirection === 'forward' ? 'Forward' : 'Backward';
309− var start = field.selectionStart;
310− var end = field.selectionEnd;
311− field.value = field.elm_old_value;
312−
313− elm.notify(field.elm_signal.id, field.elm_handler({
314− _:{},
315− string: next,
316− selection: {
317− _:{},
318− start: start,
319− end: end,
320− direction: { ctor: direction }
321− }
322− }));
323− }
324−
325− field.addEventListener('input', inputUpdate);
326− field.addEventListener('focus', function() {
327− field.elm_hasFocus = true;
328− });
329− field.addEventListener('blur', function() {
330− field.elm_hasFocus = false;
331− });
332−
333− return field;
334− }
335−
336− function updateField(field, oldModel, newModel) {
337− if (oldModel.style !== newModel.style) {
338− updateFieldStyle(field.style, newModel.style);
339− }
340− field.elm_signal = newModel.signal;
341− field.elm_handler = newModel.handler;
342−
343− field.type = newModel.type;
344− field.placeholder = newModel.placeHolder;
345− var value = newModel.content.string;
346− field.value = value;
347− field.elm_old_value = value;
348− if (field.elm_hasFocus) {
349− var selection = newModel.content.selection;
350− var direction = selection.direction.ctor === 'Forward' ? 'forward' : 'backward';
351− setRange(field, selection.start, selection.end, direction);
352− }
353− }
354−
355− function mkField(type) {
356− function field(style, signal, handler, placeHolder, content) {
357− var padding = style.padding;
358− var outline = style.outline.width;
359− var adjustWidth = padding.left + padding.right + outline.left + outline.right;
360− var adjustHeight = padding.top + padding.bottom + outline.top + outline.bottom;
361− return A3(newElement, 200, 30, {
362− ctor: 'Custom',
363− type: type + 'Field',
364− adjustWidth: adjustWidth,
365− adjustHeight: adjustHeight,
366− render: renderField,
367− update: updateField,
368− model: {
369− signal:signal,
370− handler:handler,
371− placeHolder:placeHolder,
372− content:content,
373− style:style,
374− type:type
375− }
376− });
377− }
378− return F5(field);
379− }
380−
381− function hoverable(signal, handler, elem) {
382− function onHover(bool) {
383− elm.notify(signal.id, handler(bool));
384− }
385− var props = Utils.replace([['hover',onHover]], elem.props);
386− return { props:props, element:elem.element };
387− }
388−
389− function clickable(signal, value, elem) {
390− function onClick(bool) {
391− elm.notify(signal.id, value);
392− }
393− var props = Utils.replace([['click',onClick]], elem.props);
394− return { props:props, element:elem.element };
395− }
396−
397− return elm.Native.Graphics.Input.values = {
398− input:input,
399− button:F3(button),
400− customButton:F5(customButton),
401− checkbox:F3(checkbox),
402− dropDown:F2(dropDown),
403− field:mkField('text'),
404− email:mkField('email'),
405− password:mkField('password'),
406− hoverable:F3(hoverable),
407− clickable:F3(clickable)
408− };
409−
410−};
libraries/Native/JavaScript.jsdeleted−68
@@ -1,68 +0,0 @@
1−Elm.Native.JavaScript = {};
2−Elm.Native.JavaScript.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.JavaScript = elm.Native.JavaScript || {};
5− if (elm.Native.JavaScript.values) return elm.Native.JavaScript.values;
6−
7− var List = Elm.Native.List.make(elm);
8− var Render = ElmRuntime.use(ElmRuntime.Render.Element);
9−
10− function fromJS(v) {
11− var type = typeof v;
12− if (type === 'number' ) return v;
13− if (type === 'boolean') return v;
14− if (type === 'string' ) return v;
15− if (v instanceof Array) {
16− var arr = [];
17− var len = v.length;
18− for (var i = 0; i < len; ++i) {
19− var x = fromJS(v[i]);
20− if (x !== null) arr.push(x);
21− }
22− return List.fromArray(arr);
23− }
24− if (type === 'object') {
25− var rec = { _:{} };
26− for (var f in v) {
27− var x = fromJS(v[f]);
28− if (x !== null) rec[f] = x;
29− }
30− return rec;
31− }
32− return null;
33− }
34−
35− function toJS(v) {
36− var type = typeof v;
37− if (type === 'number' || type === 'boolean' || type === 'string') return v;
38− if (type === 'object' && '_' in v) {
39− var obj = {};
40− for (var k in v) {
41− var x = toJS(v[k]);
42− if (x !== null) obj[k] = x;
43− }
44− return obj;
45− }
46− if (type === 'object' && (v.ctor === '::' || v.ctor === '[]')) {
47− var array = List.toArray(v);
48− for (var i = array.length; i--; ) {
49− array[i] = toJS(array[i]);
50− }
51− return array;
52− }
53− return null;
54− }
55−
56− function fromRecord(r) {
57− if (typeof r === 'object' && '_' in r) {
58− return toJS(r);
59− }
60− throw new Error("'fromRecord' must be called on a record.");
61− }
62−
63− return elm.Native.JavaScript.values = {
64− toRecord : fromJS,
65− fromRecord : fromRecord
66− };
67−
68−};
libraries/Native/Json.jsdeleted−85
@@ -1,85 +0,0 @@
1−Elm.Native.Json = {};
2−Elm.Native.Json.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Json = elm.Native.Json || {};
6− if (elm.Native.Json.values) return elm.Native.Json.values;
7−
8− var Maybe = Elm.Maybe.make(elm);
9− var Dict = Elm.Dict.make(elm);
10− var List = Elm.Native.List.make(elm);
11− var Utils = Elm.Native.Utils.make(elm);
12−
13− function toJS(v) {
14− switch (v.ctor) {
15− case 'Null' : return null;
16− case 'String' : return v._0;
17− case 'Number' : return v._0;
18− case 'Boolean': return v._0;
19− case 'Object' :
20− var obj = {};
21− var array = List.toArray(Dict.toList(v._0));
22− for (var i = array.length; i--; ) {
23− var entry = array[i];
24− obj[entry._0] = toJS(entry._1);
25− }
26− return obj;
27− case 'Array' :
28− var array = List.toArray(v._0);
29− for (var i = array.length; i--; ) {
30− array[i] = toJS(array[i]);
31− }
32− return array;
33− }
34− }
35−
36− function toString(sep, value) {
37− return JSON.stringify(toJS(value), null, sep);
38− }
39−
40− function fromJS(v) {
41− switch (typeof v) {
42− case 'string' : return { ctor:"String" , _0: v };
43− case 'number' : return { ctor:"Number" , _0: v };
44− case 'boolean': return { ctor:"Boolean", _0: v };
45− case 'object' :
46− if (v === null) return { ctor:"Null" };
47− if (v instanceof Array) {
48− var array = new Array(v.length);
49− for (var i = v.length; i--; ) {
50− array[i] = fromJS(v[i]);
51− }
52− return {
53− ctor:"Array",
54− _0: List.fromArray(array)
55− };
56− }
57− var array = [];
58− for (var key in v) {
59− var value = fromJS(v[key]);
60− array.push(Utils.Tuple2(key, value));
61− }
62− var list = List.fromArray(array);
63− return {
64− ctor:"Object",
65− _0: Dict.fromList(list)
66− };
67− }
68− }
69−
70− function fromString(str) {
71− try {
72− return Maybe.Just(fromJS(JSON.parse(str)));
73− } catch (e) {
74− return Maybe.Nothing;
75− }
76− }
77−
78− return elm.Native.Json.values = {
79− toString : F2(toString),
80− fromString : fromString,
81− fromJS : fromJS,
82− toJS : toJS
83− };
84−
85−};
libraries/Native/List.jsdeleted−395
@@ -1,395 +0,0 @@
1−Elm.Native.List = {};
2−Elm.Native.List.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.List = elm.Native.List || {};
5− if (elm.Native.List.values) return elm.Native.List.values;
6− if ('values' in Elm.Native.List)
7− return elm.Native.List.values = Elm.Native.List.values;
8−
9− var Utils = Elm.Native.Utils.make(elm);
10−
11− // TODO: Improve Nil handling
12− // We can change places like: if (xs.ctor === '[]') ... to if (xs === Nil) ...
13− // but only if we're confident Nil can only be defined once.
14− // Currently (27Mar2013) each module can have different instantiations, so multiple Nil objects can exist
15− // (and if they're used interchangeably then direct object comparison fails where ctor doesn't).
16− // So, this can only be fixed when modules initialisation is also fixed.
17− // The performance overhead of the .ctor calls is 5-10% according to jsperf (depending on fn + list size)
18− // (on firefox 19)
19−
20− var Nil = { ctor:'[]' };
21−
22− // using freeze for every cons would be nice but is a huge (9x on firefox 19)
23− // performance penalty
24− function Cons(hd,tl) { return { ctor:"::", _0:hd, _1:tl }; }
25−
26− function throwError(f) {
27− throw new Error("Function '" + f + "' expects a non-empty list!");
28− }
29−
30− function toArray(xs) {
31− var out = [];
32− while (xs.ctor !== '[]') {
33− out.push(xs._0);
34− xs = xs._1;
35− }
36− return out;
37− }
38−
39− function fromArray(arr) {
40− var out = Nil;
41− for (var i = arr.length; i--; ) {
42− out = Cons(arr[i], out);
43− }
44− return out;
45− }
46−
47− function range(lo,hi) {
48− var lst = Nil;
49− if (lo <= hi) {
50− do { lst = Cons(hi,lst) } while (hi-->lo);
51− }
52− return lst
53− }
54−
55− function append(xs,ys) {
56− // append Text
57− if (xs.text || ys.text) {
58− return Utils.txt(Utils.makeText(xs) + Utils.makeText(ys));
59− }
60−
61− // append Strings
62− if (typeof xs === "string") return xs + ys;
63−
64− // append Lists
65− if (xs.ctor === '[]') { return ys; }
66− var root = Cons(xs._0, Nil);
67− var curr = root;
68− xs = xs._1;
69− while (xs.ctor !== '[]') {
70− curr._1 = Cons(xs._0, Nil);
71− xs = xs._1;
72− curr = curr._1;
73− }
74− curr._1 = ys;
75− return root;
76− }
77−
78− function head(v) { return v.ctor === '[]' ? throwError('head') : v._0; }
79− function tail(v) { return v.ctor === '[]' ? throwError('tail') : v._1; }
80−
81− function last(xs) {
82− if (xs.ctor === '[]') { throwError('last'); }
83− var out = xs._0;
84− while (xs.ctor !== '[]') {
85− out = xs._0;
86− xs = xs._1;
87− }
88− return out;
89− }
90−
91− function map(f, xs) {
92− var arr = [];
93− while (xs.ctor !== '[]') {
94− arr.push(f(xs._0));
95− xs = xs._1;
96− }
97− return fromArray(arr);
98− }
99−
100− // f defined similarly for both foldl and foldr (NB: different from Haskell)
101− // ie, foldl : (a -> b -> b) -> b -> [a] -> b
102− function foldl(f, b, xs) {
103− var acc = b;
104− while (xs.ctor !== '[]') {
105− acc = A2(f, xs._0, acc);
106− xs = xs._1;
107− }
108− return acc;
109− }
110−
111− function foldr(f, b, xs) {
112− var arr = toArray(xs);
113− var acc = b;
114− for (var i = arr.length; i--; ) {
115− acc = A2(f, arr[i], acc);
116− }
117− return acc;
118− }
119−
120− function foldl1(f, xs) {
121− return xs.ctor === '[]' ? throwError('foldl1') : foldl(f, xs._0, xs._1);
122− }
123−
124− function foldr1(f, xs) {
125− if (xs.ctor === '[]') { throwError('foldr1'); }
126− var arr = toArray(xs);
127− var acc = arr.pop();
128− for (var i = arr.length; i--; ) {
129− acc = A2(f, arr[i], acc);
130− }
131− return acc;
132− }
133−
134− function scanl(f, b, xs) {
135− var arr = toArray(xs);
136− arr.unshift(b);
137− var len = arr.length;
138− for (var i = 1; i < len; ++i) {
139− arr[i] = A2(f, arr[i], arr[i-1]);
140− }
141− return fromArray(arr);
142− }
143−
144− function scanl1(f, xs) {
145− return xs.ctor === '[]' ? throwError('scanl1') : scanl(f, xs._0, xs._1);
146− }
147−
148− function filter(pred, xs) {
149− var arr = [];
150− while (xs.ctor !== '[]') {
151− if (pred(xs._0)) { arr.push(xs._0); }
152− xs = xs._1;
153− }
154− return fromArray(arr);
155− }
156−
157− function length(xs) {
158− var out = 0;
159− while (xs.ctor !== '[]') {
160− out += 1;
161− xs = xs._1;
162− }
163− return out;
164− }
165−
166− function member(x, xs) {
167− while (xs.ctor !== '[]') {
168− if (Utils.eq(x,xs._0)) return true;
169− xs = xs._1;
170− }
171− return false;
172− }
173−
174− function reverse(xs) { return fromArray(toArray(xs).reverse()); }
175−
176− function concat(xss) {
177− if (xss.ctor === '[]') return xss;
178− var arr = toArray(xss);
179− var xs = arr[arr.length-1];
180− for (var i = arr.length-1; i--; ) {
181− xs = append(arr[i], xs);
182− }
183− return xs;
184− }
185−
186− function all(pred, xs) {
187− while (xs.ctor !== '[]') {
188− if (!pred(xs._0)) return false;
189− xs = xs._1;
190− }
191− return true;
192− }
193−
194− function any(pred, xs) {
195− while (xs.ctor !== '[]') {
196− if (pred(xs._0)) return true;
197− xs = xs._1;
198− }
199− return false;
200− }
201−
202− function zip(xs, ys) {
203− var arr = [];
204− while (xs.ctor !== '[]' && ys.ctor !== '[]') {
205− arr.push(Utils.Tuple2(xs._0, ys._0));
206− xs = xs._1;
207− ys = ys._1;
208− }
209− return fromArray(arr);
210− }
211−
212− function zipWith(f, xs, ys) {
213− var arr = [];
214− while (xs.ctor !== '[]' && ys.ctor !== '[]') {
215− arr.push(A2(f, xs._0, ys._0));
216− xs = xs._1;
217− ys = ys._1;
218− }
219− return fromArray(arr);
220− }
221−
222− function zipWith3(f, xs, ys, zs) {
223− var arr = [];
224− while (xs.ctor !== '[]' && ys.ctor !== '[]' && zs.ctor !== '[]') {
225− arr.push(A3(f, xs._0, ys._0, zs._0));
226− xs = xs._1;
227− ys = ys._1;
228− zs = zs._1;
229− }
230− return fromArray(arr);
231− }
232−
233− function zipWith4(f, ws, xs, ys, zs) {
234− var arr = [];
235− while ( ws.ctor !== '[]'
236− && xs.ctor !== '[]'
237− && ys.ctor !== '[]'
238− && zs.ctor !== '[]')
239− {
240− arr.push(A4(f, ws._0, xs._0, ys._0, zs._0));
241− ws = ws._1;
242− xs = xs._1;
243− ys = ys._1;
244− zs = zs._1;
245− }
246− return fromArray(arr);
247− }
248−
249− function zipWith5(f, vs, ws, xs, ys, zs) {
250− var arr = [];
251− while ( vs.ctor !== '[]'
252− && ws.ctor !== '[]'
253− && xs.ctor !== '[]'
254− && ys.ctor !== '[]'
255− && zs.ctor !== '[]')
256− {
257− arr.push(A5(f, vs._0, ws._0, xs._0, ys._0, zs._0));
258− vs = vs._1;
259− ws = ws._1;
260− xs = xs._1;
261− ys = ys._1;
262− zs = zs._1;
263− }
264− return fromArray(arr);
265− }
266−
267− function sort(xs) {
268− return fromArray(toArray(xs).sort(Utils.cmp));
269− }
270−
271− function sortBy(f, xs) {
272− return fromArray(toArray(xs).sort(function(a,b){
273− return Utils.cmp(f(a), f(b));
274− }));
275− }
276−
277− function sortWith(f, xs) {
278− return fromArray(toArray(xs).sort(function(a,b){
279− var ord = f(a)(b).ctor;
280− return ord === 'EQ' ? 0 : ord === 'LT' ? -1 : 1;
281− }));
282− }
283−
284− function nth(xs, n) {
285− return toArray(xs)[n];
286− }
287−
288− function take(n, xs) {
289− var arr = [];
290− while (xs.ctor !== '[]' && n > 0) {
291− arr.push(xs._0);
292− xs = xs._1;
293− --n;
294− }
295− return fromArray(arr);
296− }
297−
298− function drop(n, xs) {
299− while (xs.ctor !== '[]' && n > 0) {
300− xs = xs._1;
301− --n;
302− }
303− return xs;
304− }
305−
306− function repeat(n, x) {
307− var arr = [];
308− var pattern = [x];
309− while (n > 0) {
310− if (n & 1) arr = arr.concat(pattern);
311− n >>= 1, pattern = pattern.concat(pattern);
312− }
313− return fromArray(arr);
314− }
315−
316− function join(sep, xss) {
317− if (sep.text) {
318− sep = Utils.makeText(sep);
319− xss = toArray(xss);
320− for (var i = xss.length; i--; ) {
321− xss[i] = Utils.makeText(xss[i]);
322− }
323− return Utils.txt(xss.join(sep));
324− }
325− if (typeof sep === 'string') return toArray(xss).join(sep);
326− if (xss.ctor === '[]') return Nil;
327− var s = toArray(sep);
328− var out = toArray(xss._0);
329− xss = xss._1;
330− while (xss.ctor !== '[]') {
331− out = out.concat(s, toArray(xss._0));
332− xss = xss._1;
333− }
334− return fromArray(out);
335− }
336−
337− /*
338− * Only to be used internally; do some side effects for each elem
339− */
340− function each(action, xs) {
341− while(xs.ctor !== '[]') {
342− action(xs._0);
343− xs = xs._1;
344− }
345− }
346−
347− Elm.Native.List.values = {
348− Nil:Nil,
349− Cons:Cons,
350− cons:F2(Cons),
351− toArray:toArray,
352− fromArray:fromArray,
353− range:range,
354− append:append,
355−
356− head:head,
357− tail:tail,
358− last:last,
359−
360− map:F2(map),
361− foldl:F3(foldl),
362− foldr:F3(foldr),
363−
364− foldl1:F2(foldl1),
365− foldr1:F2(foldr1),
366− scanl:F3(scanl),
367− scanl1:F2(scanl1),
368− filter:F2(filter),
369− length:length,
370− member:F2(member),
371− reverse:reverse,
372− concat:concat,
373−
374− all:F2(all),
375− any:F2(any),
376− zipWith :F3(zipWith ),
377− zipWith3:F4(zipWith3),
378− zipWith4:F5(zipWith4),
379− zipWith5:F6(zipWith5),
380− zip:F2(zip),
381− sort:sort,
382− sortBy:F2(sortBy),
383− sortWith:F2(sortWith),
384− nth:F2(nth),
385− take:F2(take),
386− drop:F2(drop),
387− repeat:F2(repeat),
388−
389− join:F2(join),
390−
391− each:each
392− };
393− return elm.Native.List.values = Elm.Native.List.values;
394−
395−};
libraries/Native/Ports.jsdeleted−83
@@ -1,83 +0,0 @@
1−Elm.Native.Ports = {};
2−Elm.Native.Ports.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Ports = elm.Native.Ports || {};
5− if (elm.Native.Ports.values) return elm.Native.Ports.values;
6−
7− var Signal = Elm.Signal.make(elm);
8−
9− function incomingSignal(converter) {
10− converter.isSignal = true;
11− return converter;
12− }
13−
14− function outgoingSignal(converter) {
15− return function(signal) {
16− var subscribers = []
17− function subscribe(handler) {
18− subscribers.push(handler);
19− }
20− function unsubscribe(handler) {
21− subscribers.pop(subscribers.indexOf(handler));
22− }
23− A2( Signal.lift, function(value) {
24− var val = converter(value);
25− var len = subscribers.length;
26− for (var i = 0; i < len; ++i) {
27− subscribers[i](val);
28− }
29− }, signal);
30− return { subscribe:subscribe, unsubscribe:unsubscribe };
31− }
32− }
33−
34− function portIn(name, converter) {
35− var jsValue = elm.ports.incoming[name];
36− if (jsValue === undefined) {
37− throw new Error("Initialization Error: port '" + name +
38− "' was not given an input!");
39− }
40− elm.ports.uses[name] += 1;
41− try {
42− var elmValue = converter(jsValue);
43− } catch(e) {
44− throw new Error("Initialization Error on port '" + name + "': \n" + e.message);
45− }
46−
47− // just return a static value if it is not a signal
48− if (!converter.isSignal) {
49− return elmValue;
50− }
51−
52− // create a signal if necessary
53− var signal = Signal.constant(elmValue);
54− function send(jsValue) {
55− try {
56− var elmValue = converter(jsValue);
57− } catch(e) {
58− throw new Error("Error sending to port '" + name + "': \n" + e.message);
59− }
60− setTimeout(function() {
61− elm.notify(signal.id, elmValue);
62− }, 0);
63− }
64− elm.ports.outgoing[name] = { send:send };
65− return signal;
66− }
67−
68− function portOut(name, converter, value) {
69− try {
70− elm.ports.outgoing[name] = converter(value);
71− } catch(e) {
72− throw new Error("Initialization Error on port '" + name + "': \n" + e.message);
73− }
74− return value;
75− }
76−
77− return elm.Native.Ports.values = {
78− incomingSignal: incomingSignal,
79− outgoingSignal: outgoingSignal,
80− portOut: portOut,
81− portIn: portIn
82− };
83−};
libraries/Native/Regex.jsdeleted−103
@@ -1,103 +0,0 @@
1−Elm.Native.Regex = {};
2−Elm.Native.Regex.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Regex = elm.Native.Regex || {};
5− if (elm.Native.Regex.values) return elm.Native.Regex.values;
6− if ('values' in Elm.Native.Regex)
7− return elm.Native.Regex.values = Elm.Native.Regex.values;
8−
9− var List = Elm.Native.List.make(elm);
10− var Maybe = Elm.Maybe.make(elm);
11−
12− function escape(str) {
13− return str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
14− }
15− function caseInsensitive(re) {
16− return new RegExp(re.source, 'gi');
17− }
18− function regex(raw) {
19− return new RegExp(raw, 'g');
20− }
21−
22− function contains(re, string) {
23− return string.match(re) !== null;
24− }
25−
26− function find(n, re, str) {
27− n = n.ctor === "All" ? Infinity : n._0;
28− var out = [];
29− var number = 0;
30− var string = str;
31− var result;
32− while (number++ < n && (result = re.exec(string))) {
33− var i = result.length - 1;
34− var subs = new Array(i);
35− while (i > 0) {
36− var submatch = result[i];
37− subs[--i] = submatch === undefined
38− ? Maybe.Nothing
39− : Maybe.Just(submatch);
40− }
41− out.push({
42− _:{},
43− match: result[0],
44− submatches: List.fromArray(subs),
45− index: result.index,
46− number: number
47− });
48− }
49− return List.fromArray(out);
50− }
51−
52− function replace(n, re, replacer, string) {
53− n = n.ctor === "All" ? Infinity : n._0;
54− var count = 0;
55− function jsReplacer(match) {
56− if (count++ > n) return match;
57− var i = arguments.length-3;
58− var submatches = new Array(i);
59− while (i > 0) {
60− var submatch = arguments[i];
61− submatches[--i] = submatch === undefined
62− ? Maybe.Nothing
63− : Maybe.Just(submatch);
64− }
65− return replacer({
66− _:{},
67− match:match,
68− submatches:List.fromArray(submatches),
69− index:arguments[i-1],
70− number:count
71− });
72− }
73− return string.replace(re, jsReplacer);
74− }
75−
76− function split(n, re, str) {
77− if (n === Infinity) {
78− return List.fromArray(string.split(re));
79− }
80− var string = str;
81− var result;
82− var out = [];
83− var start = re.lastIndex;
84− while (n--) {
85− if (!(result = re.exec(string))) break;
86− out.push(string.slice(start, result.index));
87− start = re.lastIndex;
88− }
89− out.push(string.slice(start));
90− return List.fromArray(out);
91− }
92−
93− return Elm.Native.Regex.values = {
94− regex: regex,
95− caseInsensitive: caseInsensitive,
96− escape: escape,
97−
98− contains: F2(contains),
99− find: F3(find),
100− replace: F4(replace),
101− split: F3(split)
102− };
103−};
libraries/Native/Show.jsdeleted−132
@@ -1,132 +0,0 @@
1−Elm.Native.Show = {};
2−Elm.Native.Show.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Show = elm.Native.Show || {};
5− if (elm.Native.Show.values) return elm.Native.Show.values;
6−
7− var NList = Elm.Native.List.make(elm);
8− var Array = Elm.Array.make(elm);
9− var List = Elm.List.make(elm);
10− var Dict = Elm.Dict.make(elm);
11− var Tuple2 = Elm.Native.Utils.make(elm).Tuple2;
12−
13− var toString = function(v) {
14− var type = typeof v;
15− if (type === "function") {
16− var name = v.func ? v.func.name : v.name;
17− return '<function' + (name === '' ? '' : ': ') + name + '>';
18− }
19− else if (type === "boolean") {
20− return v ? "True" : "False";
21− }
22− else if (type === "number") {
23− return v + "";
24− }
25− else if ((v instanceof String) && v.isChar) {
26− return "'" + addSlashes(v) + "'";
27− }
28− else if (type === "string") {
29− return '"' + addSlashes(v) + '"';
30− }
31− else if (type === "object" && '_' in v && probablyPublic(v)) {
32− var output = [];
33− for (var k in v._) {
34− for (var i = v._[k].length; i--; ) {
35− output.push(k + " = " + toString(v._[k][i]));
36− }
37− }
38− for (var k in v) {
39− if (k === '_') continue;
40− output.push(k + " = " + toString(v[k]));
41− }
42− if (output.length === 0) {
43− return "{}";
44− }
45− return "{ " + output.join(", ") + " }";
46− }
47− else if (type === "object" && 'ctor' in v) {
48− if (v.ctor.substring(0,6) === "_Tuple") {
49− var output = [];
50− for (var k in v) {
51− if (k === 'ctor') continue;
52− output.push(toString(v[k]));
53− }
54− return "(" + output.join(",") + ")";
55− }
56− else if (v.ctor === "_Array") {
57− var list = Array.toList(v);
58− return "Array.fromList " + toString(list);
59− }
60− else if (v.ctor === "::") {
61− var output = '[' + toString(v._0);
62− v = v._1;
63− while (v.ctor === "::") {
64− output += "," + toString(v._0);
65− v = v._1;
66− }
67− return output + ']';
68− }
69− else if (v.ctor === "[]") {
70− return "[]";
71− }
72− else if (v.ctor === "RBNode" || v.ctor === "RBEmpty") {
73− var cons = F3(function(k,v,acc){return NList.Cons(Tuple2(k,v),acc)});
74− var list = A3(Dict.foldr, cons, NList.Nil, v);
75− var name = "Dict";
76− if (list.ctor === "::" && list._0._1.ctor === "_Tuple0") {
77− name = "Set";
78− list = A2(List.map, function(x){return x._0}, list);
79− }
80− return name + ".fromList " + toString(list);
81− }
82− else {
83− var output = "";
84− for (var i in v) {
85− if (i === 'ctor') continue;
86− var str = toString(v[i]);
87− var parenless = str[0] === '{' || str[0] === '<' || str.indexOf(' ') < 0;
88− output += ' ' + (parenless ? str : '(' + str + ')');
89− }
90− return v.ctor + output;
91− }
92− }
93− if (type === 'object' && 'recv' in v) {
94− return '<signal>';
95− }
96− return "<internal structure>";
97− };
98−
99− function addSlashes(str) {
100− return str.replace(/\\/g, '\\\\')
101− .replace(/\n/g, '\\n')
102− .replace(/\t/g, '\\t')
103− .replace(/\r/g, '\\r')
104− .replace(/\v/g, '\\v')
105− .replace(/\0/g, '\\0')
106− .replace(/\'/g, "\\'")
107− .replace(/\"/g, '\\"');
108− }
109−
110− function probablyPublic(v) {
111− var keys = Object.keys(v);
112− var len = keys.length;
113− if (len === 3
114− && 'props' in v
115− && 'element' in v) return false;
116− if (len === 5
117− && 'horizontal' in v
118− && 'vertical' in v
119− && 'x' in v
120− && 'y' in v) return false;
121− if (len === 7
122− && 'theta' in v
123− && 'scale' in v
124− && 'x' in v
125− && 'y' in v
126− && 'alpha' in v
127− && 'form' in v) return false;
128− return true;
129− }
130−
131− return elm.Native.Show.values = { show:toString };
132−};
libraries/Native/Signal/Http.jsdeleted−63
@@ -1,63 +0,0 @@
1−Elm.Native.Http = {};
2−Elm.Native.Http.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Http = elm.Native.Http || {};
6− if (elm.Native.Http.values) return elm.Native.Http.values;
7−
8− var List = Elm.List.make(elm);
9− var Signal = Elm.Signal.make(elm);
10−
11− function registerReq(queue,responses) {
12− return function(req) {
13− if (req.url.length > 0) {
14− sendReq(queue,responses,req);
15− }
16− };
17− }
18−
19− function updateQueue(queue,responses) {
20− if (queue.length > 0) {
21− elm.notify(responses.id, queue[0].value);
22− if (queue[0].value.ctor !== 'Waiting') {
23− queue.shift();
24− setTimeout(function() { updateQueue(queue,responses); }, 0);
25− }
26− }
27− }
28−
29− function sendReq(queue,responses,req) {
30− var response = { value: { ctor:'Waiting' } };
31− queue.push(response);
32−
33− var request = (window.ActiveXObject
34− ? new ActiveXObject("Microsoft.XMLHTTP")
35− : new XMLHttpRequest());
36−
37− request.onreadystatechange = function(e) {
38− if (request.readyState === 4) {
39− response.value = (request.status >= 200 && request.status < 300 ?
40− { ctor:'Success', _0:request.responseText } :
41− { ctor:'Failure', _0:request.status, _1:request.statusText });
42− setTimeout(function() { updateQueue(queue,responses); }, 0);
43− }
44− };
45− request.open(req.verb, req.url, true);
46− function setHeader(pair) {
47− request.setRequestHeader( pair._0, pair._1 );
48− }
49− A2( List.map, setHeader, req.headers );
50− request.send(req.body);
51− }
52−
53− function send(requests) {
54− var responses = Signal.constant(elm.Http.values.Waiting);
55− var sender = A2( Signal.lift, registerReq([],responses), requests );
56− function f(x) { return function(y) { return x; } }
57− return A3( Signal.lift2, f, responses, sender );
58− }
59−
60− return elm.Native.Http.values = {
61− send:send
62− };
63−};
libraries/Native/Signal/Keyboard.jsdeleted−154
@@ -1,154 +0,0 @@
1−Elm.Native.Keyboard = {};
2−Elm.Native.Keyboard.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Keyboard = elm.Native.Keyboard || {};
6− if (elm.Native.Keyboard.values) return elm.Native.Keyboard.values;
7−
8− // Duplicated from Native.Signal
9− function send(node, timestep, changed) {
10− var kids = node.kids;
11− for (var i = kids.length; i--; ) {
12− kids[i].recv(timestep, changed, node.id);
13− }
14− }
15−
16− var Signal = Elm.Signal.make(elm);
17− var NList = Elm.Native.List.make(elm);
18− var Utils = Elm.Native.Utils.make(elm);
19−
20− var downEvents = Signal.constant(null);
21− var upEvents = Signal.constant(null);
22− var blurEvents = Signal.constant(null);
23−
24− elm.addListener([downEvents.id], document, 'keydown', function down(e) {
25− elm.notify(downEvents.id, e);
26− });
27−
28− elm.addListener([upEvents.id], document, 'keyup', function up(e) {
29− elm.notify(upEvents.id, e);
30− });
31−
32− elm.addListener([blurEvents.id], window, 'blur', function blur(e) {
33− elm.notify(blurEvents.id, null);
34− });
35−
36− function state(alt, meta, keyCodes) {
37− return {
38− alt: alt,
39− meta: meta,
40− keyCodes: keyCodes
41− };
42− }
43− var emptyState = state(false, false, NList.Nil);
44−
45− function KeyMerge(down, up, blur) {
46− var args = [down,up,blur];
47− this.id = Utils.guid();
48− // Ignore starting values here
49− this.value = emptyState;
50− this.kids = [];
51−
52− var n = args.length;
53− var count = 0;
54− var isChanged = false;
55−
56− this.recv = function(timestep, changed, parentID) {
57− ++count;
58− if (changed) {
59− // We know this a change must only be one of the following cases
60− if (parentID === down.id && !A2(NList.member, down.value.keyCode, this.value.keyCodes)) {
61− isChanged = true;
62− var v = down.value;
63− var newCodes = NList.Cons(v.keyCode, this.value.keyCodes);
64− this.value = state(v.altKey, v.metaKey, newCodes);
65− }
66− else if (parentID === up.id) {
67− isChanged = true;
68− var v = up.value;
69− var notEq = function(kc) { return kc !== v.keyCode };
70− var newCodes = A2(NList.filter, notEq, this.value.keyCodes);
71− this.value = state(v.altKey, v.metaKey, newCodes);
72− }
73− else if (parentID === blur.id) {
74− isChanged = true;
75− this.value = emptyState;
76− }
77− }
78− if (count == n) {
79− send(this, timestep, isChanged);
80− isChanged = false;
81− count = 0;
82− }
83− };
84−
85− for (var i = n; i--; ) {
86− args[i].kids.push(this);
87− args[i].defaultNumberOfKids += 1;
88− }
89− }
90−
91− var keyMerge = new KeyMerge(downEvents,upEvents,blurEvents);
92−
93− // select a part of a keyMerge and dropRepeats the result
94− function keySignal(f) {
95− var signal = A2(Signal.lift, f, keyMerge);
96− // must set the default number of kids to make it possible to filter
97− // these signals if they are not actually used.
98− keyMerge.defaultNumberOfKids += 1;
99− signal.defaultNumberOfKids = 1;
100− var filtered = Signal.dropRepeats(signal);
101− filtered.defaultNumberOfKids = 0;
102− return filtered;
103− }
104−
105− // break keyMerge into parts
106− var keysDown = keySignal(function getKeyCodes(v) {
107− return v.keyCodes;
108− });
109− var alt = keySignal(function getKeyCodes(v) {
110− return v.alt;
111− });
112− var meta = keySignal(function getKeyCodes(v) {
113− return v.meta;
114− });
115−
116− function dir(up, down, left, right) {
117− function toDirections(state) {
118− var keyCodes = state.keyCodes;
119− var x = 0, y = 0;
120− while (keyCodes.ctor === "::") {
121− switch (keyCodes._0) {
122− case left : --x; break;
123− case right: ++x; break;
124− case up : ++y; break;
125− case down : --y; break;
126− }
127− keyCodes = keyCodes._1;
128− }
129− return { _:{}, x:x, y:y };
130− }
131− return keySignal(toDirections);
132− }
133−
134− function is(key) {
135− return keySignal(function(v) {
136− return A2( NList.member, key, v.keyCodes );
137− });
138− }
139−
140− var lastPressed = A2(Signal.lift, function(e) {
141− return e ? e.keyCode : 0;
142− }, downEvents);
143− downEvents.defaultNumberOfKids += 1;
144−
145− return elm.Native.Keyboard.values = {
146− isDown:is,
147− alt: alt,
148− meta: meta,
149− directions:F4(dir),
150− keysDown:keysDown,
151− lastPressed:lastPressed
152− };
153−
154−};
libraries/Native/Signal/Mouse.jsdeleted−47
@@ -1,47 +0,0 @@
1−Elm.Native.Mouse = {};
2−Elm.Native.Mouse.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Mouse = elm.Native.Mouse || {};
6− if (elm.Native.Mouse.values) return elm.Native.Mouse.values;
7−
8− var Signal = Elm.Signal.make(elm);
9− var Utils = Elm.Native.Utils.make(elm);
10−
11− var position = Signal.constant(Utils.Tuple2(0,0));
12− position.defaultNumberOfKids = 2;
13−
14− // do not move x and y into Elm. By setting their default number
15− // of kids, it is possible to detatch the mouse listeners if
16− // they are not needed.
17− var x = A2( Signal.lift, function(p){return p._0}, position);
18− x.defaultNumberOfKids = 0;
19− var y = A2( Signal.lift, function(p){return p._1}, position);
20− y.defaultNumberOfKids = 0;
21−
22− var isDown = Signal.constant(false);
23− var clicks = Signal.constant(Utils.Tuple0);
24−
25− var node = elm.display === ElmRuntime.Display.FULLSCREEN ? document : elm.node;
26−
27− elm.addListener([clicks.id], node, 'click', function click() {
28− elm.notify(clicks.id, Utils.Tuple0);
29− });
30− elm.addListener([isDown.id], node, 'mousedown', function down() {
31− elm.notify(isDown.id, true);
32− });
33− elm.addListener([isDown.id], node, 'mouseup', function up() {
34− elm.notify(isDown.id, false);
35− });
36− elm.addListener([position.id], node, 'mousemove', function move(e) {
37− elm.notify(position.id, Utils.getXY(e));
38− });
39−
40− return elm.Native.Mouse.values = {
41− position: position,
42− x:x,
43− y:y,
44− isDown: isDown,
45− clicks: clicks
46− };
47−};
libraries/Native/Signal/Random.jsdeleted−39
@@ -1,39 +0,0 @@
1−Elm.Native.Random = {};
2−Elm.Native.Random.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Random = elm.Native.Random || {};
6− if (elm.Native.Random.values) return elm.Native.Random.values;
7−
8− var Signal = Elm.Signal.make(elm);
9− var List = Elm.Native.List.make(elm);
10−
11− function range(min, max, signal) {
12− function f(x) { return Math.floor(Math.random() * (max-min+1)) + min; }
13− return A2( Signal.lift, f, signal );
14− }
15−
16− function float_(signal) {
17− function f(x) { return Math.random(); }
18− return A2( Signal.lift, f, signal );
19− }
20−
21− function floatList(signal) {
22− function f(n) {
23− if (n < 0) return List.Nil;
24− var arr = new Array(n);
25− for (var i = n; i--; ) {
26− arr[i] = Math.random();
27− }
28− return List.fromArray(arr);
29− }
30− return A2( Signal.lift, f, signal );
31− }
32−
33− return elm.Native.Random.values = {
34− range: F3(range),
35− float_: float_,
36− floatList: floatList
37− };
38−
39−};
libraries/Native/Signal/Signal.jsdeleted−227
@@ -1,227 +0,0 @@
1−
2−Elm.Native.Signal = {};
3−Elm.Native.Signal.make = function(elm) {
4−
5− elm.Native = elm.Native || {};
6− elm.Native.Signal = elm.Native.Signal || {};
7− if (elm.Native.Signal.values) return elm.Native.Signal.values;
8−
9− var Utils = Elm.Native.Utils.make(elm);
10− var foldr1 = Elm.List.make(elm).foldr1;
11−
12− function send(node, timestep, changed) {
13− var kids = node.kids;
14− for (var i = kids.length; i--; ) {
15− kids[i].recv(timestep, changed, node.id);
16− }
17− }
18−
19− function Input(base) {
20− this.id = Utils.guid();
21− this.value = base;
22− this.kids = [];
23− this.defaultNumberOfKids = 0;
24− this.recv = function(timestep, eid, v) {
25− var changed = eid === this.id;
26− if (changed) { this.value = v; }
27− send(this, timestep, changed);
28− return changed;
29− };
30− elm.inputs.push(this);
31− }
32−
33− function LiftN(update, args) {
34− this.id = Utils.guid();
35− this.value = update();
36− this.kids = [];
37−
38− var n = args.length;
39− var count = 0;
40− var isChanged = false;
41−
42− this.recv = function(timestep, changed, parentID) {
43− ++count;
44− if (changed) { isChanged = true; }
45− if (count == n) {
46− if (isChanged) { this.value = update(); }
47− send(this, timestep, isChanged);
48− isChanged = false;
49− count = 0;
50− }
51− };
52− for (var i = n; i--; ) { args[i].kids.push(this); }
53− }
54−
55− function lift(func, a) {
56− function update() { return func(a.value); }
57− return new LiftN(update, [a]);
58− }
59− function lift2(func, a, b) {
60− function update() { return A2( func, a.value, b.value ); }
61− return new LiftN(update, [a,b]);
62− }
63− function lift3(func, a, b, c) {
64− function update() { return A3( func, a.value, b.value, c.value ); }
65− return new LiftN(update, [a,b,c]);
66− }
67− function lift4(func, a, b, c, d) {
68− function update() { return A4( func, a.value, b.value, c.value, d.value ); }
69− return new LiftN(update, [a,b,c,d]);
70− }
71− function lift5(func, a, b, c, d, e) {
72− function update() { return A5( func, a.value, b.value, c.value, d.value, e.value ); }
73− return new LiftN(update, [a,b,c,d,e]);
74− }
75− function lift6(func, a, b, c, d, e, f) {
76− function update() { return A6( func, a.value, b.value, c.value, d.value, e.value, f.value ); }
77− return new LiftN(update, [a,b,c,d,e,f]);
78− }
79− function lift7(func, a, b, c, d, e, f, g) {
80− function update() { return A7( func, a.value, b.value, c.value, d.value, e.value, f.value, g.value ); }
81− return new LiftN(update, [a,b,c,d,e,f,g]);
82− }
83− function lift8(func, a, b, c, d, e, f, g, h) {
84− function update() { return A8( func, a.value, b.value, c.value, d.value, e.value, f.value, g.value, h.value ); }
85− return new LiftN(update, [a,b,c,d,e,f,g,h]);
86− }
87−
88− function Foldp(step, state, input) {
89− this.id = Utils.guid();
90− this.value = state;
91− this.kids = [];
92−
93− this.recv = function(timestep, changed, parentID) {
94− if (changed) {
95− this.value = A2( step, input.value, this.value );
96− }
97− send(this, timestep, changed);
98− };
99− input.kids.push(this);
100− }
101−
102− function foldp(step, state, input) {
103− return new Foldp(step, state, input);
104− }
105−
106− function DropIf(pred,base,input) {
107− this.id = Utils.guid();
108− this.value = pred(input.value) ? base : input.value;
109− this.kids = [];
110− this.recv = function(timestep, changed, parentID) {
111− var chng = changed && !pred(input.value);
112− if (chng) { this.value = input.value; }
113− send(this, timestep, chng);
114− };
115− input.kids.push(this);
116− }
117−
118− function DropRepeats(input) {
119− this.id = Utils.guid();
120− this.value = input.value;
121− this.kids = [];
122− this.recv = function(timestep, changed, parentID) {
123− var chng = changed && !Utils.eq(this.value,input.value);
124− if (chng) { this.value = input.value; }
125− send(this, timestep, chng);
126− };
127− input.kids.push(this);
128− }
129−
130− function timestamp(a) {
131− function update() { return Utils.Tuple2(elm.timer.now(), a.value); }
132− return new LiftN(update, [a]);
133− }
134−
135− function SampleOn(s1,s2) {
136− this.id = Utils.guid();
137− this.value = s2.value;
138− this.kids = [];
139−
140− var count = 0;
141− var isChanged = false;
142−
143− this.recv = function(timestep, changed, parentID) {
144− if (parentID === s1.id) isChanged = changed;
145− ++count;
146− if (count == 2) {
147− if (isChanged) { this.value = s2.value; }
148− send(this, timestep, isChanged);
149− count = 0;
150− isChanged = false;
151− }
152− };
153− s1.kids.push(this);
154− s2.kids.push(this);
155− }
156−
157− function sampleOn(s1,s2) { return new SampleOn(s1,s2); }
158−
159− function delay(t,s) {
160− var delayed = new Input(s.value);
161− var firstEvent = true;
162− function update(v) {
163− if (firstEvent) { firstEvent = false; return; }
164− setTimeout(function() { elm.notify(delayed.id, v); }, t);
165− }
166− function first(a,b) { return a; }
167− return new SampleOn(delayed, lift2(F2(first), delayed, lift(update,s)));
168− }
169−
170− function Merge(s1,s2) {
171− this.id = Utils.guid();
172− this.value = s1.value;
173− this.kids = [];
174−
175− var next = null;
176− var count = 0;
177− var isChanged = false;
178−
179− this.recv = function(timestep, changed, parentID) {
180− ++count;
181− if (changed) {
182− isChanged = true;
183− if (parentID == s2.id && next === null) { next = s2.value; }
184− if (parentID == s1.id) { next = s1.value; }
185− }
186−
187− if (count == 2) {
188− if (isChanged) { this.value = next; next = null; }
189− send(this, timestep, isChanged);
190− isChanged = false;
191− count = 0;
192− }
193− };
194− s1.kids.push(this);
195− s2.kids.push(this);
196− }
197−
198− function merge(s1,s2) { return new Merge(s1,s2); }
199− function merges(ss) { return A2(foldr1, F2(merge), ss); }
200−
201− return elm.Native.Signal.values = {
202− input: function(v) { return new Input(v); },
203− constant : function(v) { return new Input(v); },
204− lift : F2(lift ),
205− lift2 : F3(lift2),
206− lift3 : F4(lift3),
207− lift4 : F5(lift4),
208− lift5 : F6(lift5),
209− lift6 : F7(lift6),
210− lift7 : F8(lift7),
211− lift8 : F9(lift8),
212− foldp : F3(foldp),
213− delay : F2(delay),
214− merge : F2(merge),
215− merges : merges,
216− count : function(s) { return foldp(F2(function(_,c) { return c+1; }), 0, s); },
217− countIf : F2(function(pred,s) {
218− return foldp(F2(function(x,c){
219− return pred(x) ? c+1 : c; }), 0, s)}),
220− keepIf : F3(function(pred,base,sig) {
221− return new DropIf(function(x) {return !pred(x);},base,sig); }),
222− dropIf : F3(function(pred,base,sig) { return new DropIf(pred,base,sig); }),
223− dropRepeats : function(s) { return new DropRepeats(s);},
224− sampleOn : F2(sampleOn),
225− timestamp : timestamp
226− };
227−};
libraries/Native/Signal/Time.jsdeleted−70
@@ -1,70 +0,0 @@
1−Elm.Native.Time = {};
2−Elm.Native.Time.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Time = elm.Native.Time || {};
6− if (elm.Native.Time.values) return elm.Native.Time.values;
7−
8− var Signal = Elm.Signal.make(elm);
9− var NS = Elm.Native.Signal.make(elm);
10− var Maybe = Elm.Maybe.make(elm);
11− var Utils = Elm.Native.Utils.make(elm);
12−
13− function fpsWhen(desiredFPS, isOn) {
14− var msPerFrame = 1000 / desiredFPS;
15− var prev = elm.timer.now(), curr = prev, diff = 0, wasOn = true;
16− var ticker = NS.input(diff);
17− function tick(zero) {
18− return function() {
19− curr = elm.timer.now();
20− diff = zero ? 0 : curr - prev;
21− if (prev > curr) {
22− diff = 0;
23− }
24− prev = curr;
25− elm.notify(ticker.id, diff);
26− };
27− }
28− var timeoutID = 0;
29− function f(isOn, t) {
30− if (isOn) {
31− timeoutID = elm.setTimeout(tick(!wasOn && isOn), msPerFrame);
32− } else if (wasOn) {
33− clearTimeout(timeoutID);
34− }
35− wasOn = isOn;
36− return t;
37− }
38− return A3( Signal.lift2, F2(f), isOn, ticker );
39− }
40−
41− function every(t) {
42− var clock = NS.input(elm.timer.now());
43− function tellTime() {
44− elm.notify(clock.id, elm.timer.now());
45− }
46− setInterval(tellTime, t);
47− return clock;
48− }
49−
50− function since(t, s) {
51− function cmp(a,b) { return !Utils.eq(a,b); }
52− var dcount = Signal.count(A2(NS.delay, t, s));
53− return A3( Signal.lift2, F2(cmp), Signal.count(s), dcount );
54− }
55− function read(s) {
56− var t = Date.parse(s);
57− return isNaN(t) ? Maybe.Nothing : Maybe.Just(t);
58− }
59− return elm.Native.Time.values = {
60− fpsWhen : F2(fpsWhen),
61− fps : function(t) { return fpsWhen(t, Signal.constant(true)); },
62− every : every,
63− delay : NS.delay,
64− timestamp : NS.timestamp,
65− since : F2(since),
66− toDate : function(t) { return new window.Date(t); },
67− read : read
68− };
69−
70−};
libraries/Native/Signal/Touch.jsdeleted−152
@@ -1,152 +0,0 @@
1−Elm.Native.Touch = {};
2−Elm.Native.Touch.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Touch = elm.Native.Touch || {};
6− if (elm.Native.Touch.values) return elm.Native.Touch.values;
7−
8− var Signal = Elm.Signal.make(elm);
9− var List = Elm.Native.List.make(elm);
10− var Utils = Elm.Native.Utils.make(elm);
11−
12− function Dict() {
13− this.keys = [];
14− this.values = [];
15−
16− this.insert = function(key,value) {
17− this.keys.push(key);
18− this.values.push(value);
19− };
20− this.lookup = function(key) {
21− var i = this.keys.indexOf(key)
22− return i >= 0 ? this.values[i] : {x:0,y:0,t:0};
23− };
24− this.remove = function(key) {
25− var i = this.keys.indexOf(key);
26− if (i < 0) return;
27− var t = this.values[i];
28− this.keys.splice(i,1);
29− this.values.splice(i,1);
30− return t;
31− };
32− this.clear = function() {
33− this.keys = [];
34− this.values = [];
35− };
36− }
37−
38− var root = Signal.constant([]),
39− tapTime = 500,
40− hasTap = false,
41− tap = {_:{},x:0,y:0},
42− dict = new Dict();
43−
44− function touch(t) {
45− var r = dict.lookup(t.identifier);
46− var point = Utils.getXY(t);
47− return {_ : {},
48− id: t.identifier,
49− x : point._0,
50− y : point._1,
51− x0: r.x,
52− y0: r.y,
53− t0: r.t
54− };
55− }
56−
57− var node = elm.display === ElmRuntime.Display.FULLSCREEN ? document : elm.node;
58−
59− function start(e) {
60− var point = Utils.getXY(e);
61− dict.insert(e.identifier,
62− {x: point._0,
63− y: point._1,
64− t: elm.timer.now()});
65− }
66− function end(e) {
67− var t = dict.remove(e.identifier);
68− if (elm.timer.now() - t.t < tapTime) {
69− hasTap = true;
70− tap = {_:{}, x:t.x, y:t.y};
71− }
72− }
73−
74− function listen(name, f) {
75− function update(e) {
76− for (var i = e.changedTouches.length; i--; ) { f(e.changedTouches[i]); }
77− var ts = new Array(e.touches.length);
78− for (var i = e.touches.length; i--; ) { ts[i] = touch(e.touches[i]); }
79− elm.notify(root.id, ts);
80− e.preventDefault();
81− }
82− elm.addListener([root.id], node, name, update);
83− }
84−
85− listen("touchstart", start);
86− listen("touchmove", function(_){});
87− listen("touchend", end);
88− listen("touchcancel", end);
89− listen("touchleave", end);
90−
91− var mouseID = -1;
92− function move(e) {
93− var point = Utils.getXY(e);
94− for (var i = root.value.length; i--; ) {
95− if (root.value[i].id === mouseID) {
96− root.value[i].x = point._0;
97− root.value[i].y = point._1;
98− elm.notify(root.id, root.value);
99− break;
100− }
101− }
102− }
103− elm.addListener([root.id], node, "mousedown", function down(e) {
104− node.addEventListener("mousemove", move);
105− e.identifier = mouseID;
106− start(e);
107− root.value.push(touch(e));
108− elm.notify(root.id, root.value);
109− });
110− elm.addListener([root.id], document, "mouseup", function up(e) {
111− node.removeEventListener("mousemove", move);
112− e.identifier = mouseID;
113− end(e);
114− for (var i = root.value.length; i--; ) {
115− if (root.value[i].id === mouseID) {
116− root.value.splice(i, 1);
117− --mouseID;
118− break;
119− }
120− }
121− elm.notify(root.id, root.value);
122− });
123− elm.addListener([root.id], node, "blur", function blur(e) {
124− node.removeEventListener("mousemove", move);
125− if (root.value.length > 0) {
126− elm.notify(root.id, []);
127− --mouseID;
128− }
129− dict.clear();
130− });
131−
132− function dependency(f) {
133− var sig = A2( Signal.lift, f, root );
134− root.defaultNumberOfKids += 1;
135− sig.defaultNumberOfKids = 0;
136− return sig;
137− }
138−
139− var touches = dependency(List.fromArray);
140−
141− var taps = function() {
142− var sig = dependency(function(_) { return tap; });
143− sig.defaultNumberOfKids = 1;
144− function pred(_) { var b = hasTap; hasTap = false; return b; }
145− var sig2 = A3( Signal.keepIf, pred, {_:{},x:0,y:0}, sig);
146− sig2.defaultNumberOfKids = 0;
147− return sig2;
148− }();
149−
150− return elm.Native.Touch.values = { touches: touches, taps: taps };
151−
152−};
libraries/Native/Signal/WebSocket.jsdeleted−36
@@ -1,36 +0,0 @@
1−Elm.Native.WebSocket = {};
2−Elm.Native.WebSocket.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.WebSocket = elm.Native.WebSocket || {};
6− if (elm.Native.WebSocket.values) return elm.Native.WebSocket.values;
7−
8− var Signal = Elm.Signal.make(elm);
9− var List = Elm.Native.List.make(elm);
10−
11− function open(url, outgoing) {
12− var incoming = Signal.constant("");
13− var ws = new WebSocket(url);
14−
15− var pending = [];
16− var ready = false;
17−
18− ws.onopen = function(e) {
19− var len = pending.length;
20− for (var i = 0; i < len; ++i) { ws.send(pending[i]); }
21− ready = true;
22− };
23− ws.onmessage = function(event) {
24− elm.notify(incoming.id, event.data);
25− };
26−
27− function send(msg) {
28− ready ? ws.send(msg) : pending.push(msg);
29− }
30−
31− function take1(x,y) { return x }
32− return A3(Signal.lift2, F2(take1), incoming, A2(Signal.lift, send, outgoing));
33− }
34−
35− return elm.Native.WebSocket.values = { connect: F2(open) };
36−};
libraries/Native/Signal/Window.jsdeleted−57
@@ -1,57 +0,0 @@
1−Elm.Native.Window = {};
2−Elm.Native.Window.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Window = elm.Native.Window || {};
6− if (elm.Native.Window.values) return elm.Native.Window.values;
7−
8− var Signal = Elm.Signal.make(elm);
9− var NS = Elm.Native.Signal.make(elm);
10− var Tuple2 = Elm.Native.Utils.make(elm).Tuple2;
11−
12− function getWidth() { return elm.node.clientWidth; }
13− function getHeight() {
14− if (elm.display === ElmRuntime.Display.FULLSCREEN) {
15− return window.innerHeight;
16− }
17− return elm.node.clientHeight;
18− }
19−
20− var dimensions = NS.input(Tuple2(getWidth(), getHeight()));
21− dimensions.defaultNumberOfKids = 2;
22−
23− // Do not move width and height into Elm. By setting the default number of kids,
24− // the resize listener can be detached.
25− var width = A2(Signal.lift, function(p){return p._0;}, dimensions);
26− width.defaultNumberOfKids = 0;
27−
28− var height = A2(Signal.lift, function(p){return p._1;}, dimensions);
29− height.defaultNumberOfKids = 0;
30−
31− function resizeIfNeeded() {
32− // Do not trigger event if the dimensions have not changed.
33− // This should be most of the time.
34− var w = getWidth();
35− var h = getHeight();
36− if (dimensions.value._0 === w && dimensions.value._1 === h) return;
37−
38− setTimeout(function () {
39− // Check again to see if the dimensions have changed.
40− // It is conceivable that the dimensions have changed
41− // again while some other event was being processed.
42− var w = getWidth();
43− var h = getHeight();
44− if (dimensions.value._0 === w && dimensions.value._1 === h) return;
45− elm.notify(dimensions.id, Tuple2(w,h));
46− }, 0);
47− }
48− elm.addListener([dimensions.id], window, 'resize', resizeIfNeeded);
49−
50− return elm.Native.Window.values = {
51− dimensions:dimensions,
52− width:width,
53− height:height,
54− resizeIfNeeded:resizeIfNeeded
55− };
56−
57−};
libraries/Native/String.jsdeleted−252
@@ -1,252 +0,0 @@
1−Elm.Native.String = {};
2−Elm.Native.String.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.String = elm.Native.String || {};
5− if (elm.Native.String.values) return elm.Native.String.values;
6− if ('values' in Elm.Native.String)
7− return elm.Native.String.values = Elm.Native.String.values;
8−
9− var Char = Elm.Char.make(elm);
10− var Maybe = Elm.Maybe.make(elm);
11− var List = Elm.Native.List.make(elm);
12− var Utils = Elm.Native.Utils.make(elm);
13−
14− function isEmpty(str) {
15− return str.length === 0;
16− }
17− function cons(chr,str) {
18− return chr + str;
19− }
20− function uncons(str) {
21− var hd;
22− return (hd = str[0]) ? Maybe.Just(Utils.Tuple2(Utils.chr(hd), str.slice(1)))
23− : Maybe.Nothing;
24− }
25− function append(a,b) {
26− return a + b;
27− }
28− function concat(strs) {
29− return List.toArray(strs).join('');
30− }
31− function length(str) {
32− return str.length;
33− }
34− function map(f,str) {
35− var out = str.split('');
36− for (var i = out.length; i--; ) {
37− out[i] = f(Utils.chr(out[i]));
38− }
39− return out.join('');
40− }
41− function filter(pred,str) {
42− return str.split('').map(Utils.chr).filter(pred).join('');
43− }
44− function reverse(str) {
45− return str.split('').reverse().join('');
46− }
47− function foldl(f,b,str) {
48− var len = str.length;
49− for (var i = 0; i < len; ++i) {
50− b = A2(f, Utils.chr(str[i]), b);
51− }
52− return b;
53− }
54− function foldr(f,b,str) {
55− for (var i = str.length; i--; ) {
56− b = A2(f, Utils.chr(str[i]), b);
57− }
58− return b;
59− }
60−
61− function split(sep, str) {
62− return List.fromArray(str.split(sep));
63− }
64− function join(sep, strs) {
65− return List.toArray(strs).join(sep);
66− }
67− function repeat(n, str) {
68− var result = '';
69− while (n > 0) {
70− if (n & 1) result += str;
71− n >>= 1, str += str;
72− }
73− return result;
74− }
75−
76− function slice(start, end, str) {
77− return str.slice(start,end);
78− }
79− function left(n, str) {
80− return n < 1 ? "" : str.slice(0,n);
81− }
82− function right(n, str) {
83− return n < 1 ? "" : str.slice(-n);
84− }
85− function dropLeft(n, str) {
86− return n < 1 ? str : str.slice(n);
87− }
88− function dropRight(n, str) {
89− return n < 1 ? str : str.slice(0,-n);
90− }
91−
92− function pad(n,chr,str) {
93− var half = (n - str.length) / 2;
94− return repeat(Math.ceil(half),chr) + str + repeat(half|0,chr);
95− }
96− function padRight(n,chr,str) {
97− return str + repeat(n - str.length, chr);
98− }
99− function padLeft(n,chr,str) {
100− return repeat(n - str.length, chr) + str;
101− }
102−
103− function trim(str) {
104− return str.trim();
105− }
106− function trimLeft(str) {
107− return str.trimLeft();
108− }
109− function trimRight(str) {
110− return str.trimRight();
111− }
112−
113− function words(str) {
114− return List.fromArray(str.trim().split(/\s+/g));
115− }
116− function lines(str) {
117− return List.fromArray(str.split(/\r\n|\r|\n/g));
118− }
119−
120− function toUpper(str) {
121− return str.toUpperCase();
122− }
123− function toLower(str) {
124− return str.toLowerCase();
125− }
126−
127− function any(pred, str) {
128− for (var i = str.length; i--; ) {
129− if (pred(Utils.chr(str[i]))) return true;
130− }
131− return false;
132− }
133− function all(pred, str) {
134− for (var i = str.length; i--; ) {
135− if (!pred(Utils.chr(str[i]))) return false;
136− }
137− return true;
138− }
139−
140− function contains(sub, str) {
141− return str.indexOf(sub) > -1;
142− }
143− function startsWith(sub, str) {
144− return str.indexOf(sub) === 0;
145− }
146− function endsWith(sub, str) {
147− return str.length >= sub.length &&
148− str.lastIndexOf(sub) === str.length - sub.length;
149− }
150− function indexes(sub, str) {
151− var subLen = sub.length;
152− var i = 0;
153− var is = [];
154− while ((i = str.indexOf(sub, i)) > -1) {
155− is.push(i);
156− i = i + subLen;
157− }
158− return List.fromArray(is);
159− }
160−
161− function toInt(s) {
162− var len = s.length;
163− if (len === 0) { return Maybe.Nothing; }
164− var start = 0;
165− if (s[0] == '-') {
166− if (len === 1) { return Maybe.Nothing; }
167− start = 1;
168− }
169− for (var i = start; i < len; ++i) {
170− if (!Char.isDigit(s[i])) { return Maybe.Nothing; }
171− }
172− return Maybe.Just(parseInt(s, 10));
173− }
174−
175− function toFloat(s) {
176− var len = s.length;
177− if (len === 0) { return Maybe.Nothing; }
178− var start = 0;
179− if (s[0] == '-') {
180− if (len === 1) { return Maybe.Nothing; }
181− start = 1;
182− }
183− var dotCount = 0;
184− for (var i = start; i < len; ++i) {
185− if (Char.isDigit(s[i])) { continue; }
186− if (s[i] === '.') {
187− dotCount += 1;
188− if (dotCount <= 1) { continue; }
189− }
190− return Maybe.Nothing;
191− }
192− return Maybe.Just(parseFloat(s));
193− }
194−
195− function toList(str) {
196− return List.fromArray(str.split('').map(Utils.chr));
197− }
198− function fromList(chars) {
199− return List.toArray(chars).join('');
200− }
201−
202− return Elm.Native.String.values = {
203− isEmpty: isEmpty,
204− cons: F2(cons),
205− uncons: uncons,
206− append: F2(append),
207− concat: concat,
208− length: length,
209− map: F2(map),
210− filter: F2(filter),
211− reverse: reverse,
212− foldl: F3(foldl),
213− foldr: F3(foldr),
214−
215− split: F2(split),
216− join: F2(join),
217− repeat: F2(repeat),
218−
219− slice: F3(slice),
220− left: F2(left),
221− right: F2(right),
222− dropLeft: F2(dropLeft),
223− dropRight: F2(dropRight),
224−
225− pad: F3(pad),
226− padLeft: F3(padLeft),
227− padRight: F3(padRight),
228−
229− trim: trim,
230− trimLeft: trimLeft,
231− trimRight: trimRight,
232−
233− words: words,
234− lines: lines,
235−
236− toUpper: toUpper,
237− toLower: toLower,
238−
239− any: F2(any),
240− all: F2(all),
241−
242− contains: F2(contains),
243− startsWith: F2(startsWith),
244− endsWith: F2(endsWith),
245− indexes: F2(indexes),
246−
247− toInt: toInt,
248− toFloat: toFloat,
249− toList: toList,
250− fromList: fromList
251− };
252−};
libraries/Native/Text.jsdeleted−167
@@ -1,167 +0,0 @@
1−Elm.Native.Text = {};
2−Elm.Native.Text.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Text = elm.Native.Text || {};
5− if (elm.Native.Text.values) return elm.Native.Text.values;
6−
7− var toCss = Elm.Native.Color.make(elm).toCss;
8− var Element = Elm.Graphics.Element.make(elm);
9− var List = Elm.Native.List.make(elm);
10− var Utils = Elm.Native.Utils.make(elm);
11−
12− function makeSpaces(s) {
13− if (s.length == 0) { return s; }
14− var arr = s.split('');
15− if (arr[0] == ' ') { arr[0] = "&nbsp;" }
16− for (var i = arr.length; --i; ) {
17− if (arr[i][0] == ' ' && arr[i-1] == ' ') {
18− arr[i-1] = arr[i-1] + arr[i];
19− arr[i] = '';
20− }
21− }
22− for (var i = arr.length; i--; ) {
23− if (arr[i].length > 1 && arr[i][0] == ' ') {
24− var spaces = arr[i].split('');
25− for (var j = spaces.length - 2; j >= 0; j -= 2) {
26− spaces[j] = '&nbsp;';
27− }
28− arr[i] = spaces.join('');
29− }
30− }
31− arr = arr.join('');
32− if (arr[arr.length-1] === " ") {
33− return arr.slice(0,-1) + '&nbsp;';
34− }
35− return arr;
36− }
37−
38− function properEscape(str) {
39− if (str.length == 0) return str;
40− str = str //.replace(/&/g, "&#38;")
41− .replace(/"/g, '&#34;')
42− .replace(/'/g, "&#39;")
43− .replace(/</g, "&#60;")
44− .replace(/>/g, "&#62;")
45− .replace(/\n/g, "<br/>");
46− var arr = str.split('<br/>');
47− for (var i = arr.length; i--; ) {
48− arr[i] = makeSpaces(arr[i]);
49− }
50− return arr.join('<br/>');
51− }
52−
53− function toText(str) { return Utils.txt(properEscape(str)); }
54−
55− // conversions from Elm values to CSS
56− function toTypefaces(list) {
57− var typefaces = List.toArray(list);
58− for (var i = typefaces.length; i--; ) {
59− var typeface = typefaces[i];
60− if (typeface.indexOf(' ') > -1) {
61− typefaces[i] = "'" + typeface + "'";
62− }
63− }
64− return typefaces.join(',');
65− }
66− function toLine(line) {
67− var ctor = line.ctor;
68− return ctor === 'Under' ? 'underline' :
69− ctor === 'Over' ? 'overline' : 'line-through';
70− }
71−
72− // setting styles of Text
73− function style(style, text) {
74− var newText = '<span style="color:' + toCss(style.color) + ';'
75− if (style.typeface.ctor !== '[]') {
76− newText += 'font-family:' + toTypefaces(style.typeface) + ';'
77− }
78− if (style.height.ctor !== "Nothing") {
79− newText += 'font-size:' + style.height._0 + 'px;';
80− }
81− if (style.bold) {
82− newText += 'font-weight:bold;';
83− }
84− if (style.italic) {
85− newText += 'font-style:italic;';
86− }
87− if (style.line.ctor !== 'Nothing') {
88− newText += 'text-decoration:' + toLine(style.line._0) + ';';
89− }
90− newText += '">' + Utils.makeText(text) + '</span>'
91− return Utils.txt(newText);
92− }
93− function height(px, text) {
94− return { style: 'font-size:' + px + 'px;', text:text }
95− }
96− function typeface(names, text) {
97− return { style: 'font-family:' + toTypefaces(names) + ';', text:text }
98− }
99− function monospace(text) {
100− return { style: 'font-family:monospace;', text:text }
101− }
102− function italic(text) {
103− return { style: 'font-style:italic;', text:text }
104− }
105− function bold(text) {
106− return { style: 'font-weight:bold;', text:text }
107− }
108− function link(href, text) {
109− return { href: toText(href), text:text };
110− }
111− function line(line, text) {
112− return { style: 'text-decoration:' + toLine(line) + ';', text:text };
113− }
114−
115− function color(color, text) {
116− return { style: 'color:' + toCss(color) + ';', text:text };
117− }
118−
119− function block(align) {
120− return function(text) {
121− var raw = {
122− ctor :'RawHtml',
123− html : Utils.makeText(text),
124− align: align,
125− guid : null,
126− args : []
127− };
128− var pos = A2(Utils.htmlHeight, 0, raw);
129− return A3(Element.newElement, pos._0, pos._1, raw);
130− }
131− }
132−
133− function markdown(text, guid) {
134− var raw = {
135− ctor:'RawHtml',
136− html: text,
137− align: null,
138− guid: guid,
139− args: []
140− };
141− var pos = A2(Utils.htmlHeight, 0, raw);
142− return A3(Element.newElement, pos._0, pos._1, raw);
143− }
144−
145− return elm.Native.Text.values = {
146− toText: toText,
147−
148− height : F2(height),
149− italic : italic,
150− bold : bold,
151− line : F2(line),
152− monospace : monospace,
153− typeface : F2(typeface),
154− color : F2(color),
155− link : F2(link),
156− style : F2(style),
157−
158− leftAligned : block('left'),
159− rightAligned : block('right'),
160− centered : block('center'),
161− justified : block('justify'),
162− markdown : markdown,
163−
164− toTypefaces:toTypefaces,
165− toLine:toLine
166− };
167−};
libraries/Native/Trampoline.jsdeleted−24
@@ -1,24 +0,0 @@
1−Elm.Native.Trampoline = {};
2−Elm.Native.Trampoline.make = function(elm) {
3− elm.Native = elm.Native || {};
4− elm.Native.Trampoline = elm.Native.Trampoline || {};
5− if (elm.Native.Trampoline.values) return elm.Native.Trampoline.values;
6−
7− // trampoline : Trampoline a -> a
8− function trampoline(t) {
9− var tramp = t;
10− while(true) {
11− switch(tramp.ctor) {
12− case "Done":
13− return tramp._0;
14− case "Continue":
15− tramp = tramp._0({ctor: "_Tuple0"});
16− continue;
17− }
18− }
19− }
20−
21− return elm.Native.Trampoline.values = {
22− trampoline:trampoline
23− };
24−};
libraries/Native/Transform2D.jsdeleted−99
@@ -1,99 +0,0 @@
1−Elm.Native.Transform2D = {};
2−Elm.Native.Transform2D.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Transform2D = elm.Native.Transform2D || {};
6− if (elm.Native.Transform2D.values) return elm.Native.Transform2D.values;
7−
8− var A;
9− if (typeof Float32Array === 'undefined') {
10− A = function(arr) {
11− this.length = arr.length;
12− this[0] = arr[0];
13− this[1] = arr[1];
14− this[2] = arr[2];
15− this[3] = arr[3];
16− this[4] = arr[4];
17− this[5] = arr[5];
18− };
19− } else {
20− A = Float32Array;
21− }
22−
23− // layout of matrix in an array is
24− //
25− // | m11 m12 dx |
26− // | m21 m22 dy |
27− // | 0 0 1 |
28− //
29− // new A([ m11, m12, dx, m21, m22, dy ])
30−
31− var identity = new A([1,0,0,0,1,0]);
32− function matrix(m11, m12, m21, m22, dx, dy) {
33− return new A([m11, m12, dx, m21, m22, dy]);
34− }
35− function rotation(t) {
36− var c = Math.cos(t);
37− var s = Math.sin(t);
38− return new A([c, -s, 0, s, c, 0]);
39− }
40− function rotate(t,m) {
41− var c = Math.cos(t);
42− var s = Math.sin(t);
43− var m11 = m[0], m12 = m[1], m21 = m[3], m22 = m[4];
44− return new A([m11*c + m12*s, -m11*s + m12*c, m[2],
45− m21*c + m22*s, -m21*s + m22*c, m[5]]);
46− }
47− /*
48− function move(xy,m) {
49− var x = xy._0;
50− var y = xy._1;
51− var m11 = m[0], m12 = m[1], m21 = m[3], m22 = m[4];
52− return new A([m11, m12, m11*x + m12*y + m[2],
53− m21, m22, m21*x + m22*y + m[5]]);
54− }
55− function scale(s,m) { return new A([m[0]*s, m[1]*s, m[2], m[3]*s, m[4]*s, m[5]]); }
56− function scaleX(x,m) { return new A([m[0]*x, m[1], m[2], m[3]*x, m[4], m[5]]); }
57− function scaleY(y,m) { return new A([m[0], m[1]*y, m[2], m[3], m[4]*y, m[5]]); }
58− function reflectX(m) { return new A([-m[0], m[1], m[2], -m[3], m[4], m[5]]); }
59− function reflectY(m) { return new A([m[0], -m[1], m[2], m[3], -m[4], m[5]]); }
60−
61− function transform(m11, m21, m12, m22, mdx, mdy, n) {
62− var n11 = n[0], n12 = n[1], n21 = n[3], n22 = n[4], ndx = n[2], ndy = n[5];
63− return new A([m11*n11 + m12*n21,
64− m11*n12 + m12*n22,
65− m11*ndx + m12*ndy + mdx,
66− m21*n11 + m22*n21,
67− m21*n12 + m22*n22,
68− m21*ndx + m22*ndy + mdy]);
69− }
70− */
71− function multiply(m, n) {
72− var m11 = m[0], m12 = m[1], m21 = m[3], m22 = m[4], mdx = m[2], mdy = m[5];
73− var n11 = n[0], n12 = n[1], n21 = n[3], n22 = n[4], ndx = n[2], ndy = n[5];
74− return new A([m11*n11 + m12*n21,
75− m11*n12 + m12*n22,
76− m11*ndx + m12*ndy + mdx,
77− m21*n11 + m22*n21,
78− m21*n12 + m22*n22,
79− m21*ndx + m22*ndy + mdy]);
80− }
81−
82− return elm.Native.Transform2D.values = {
83− identity:identity,
84− matrix:F6(matrix),
85− rotation:rotation,
86− multiply:F2(multiply)
87− /*
88− transform:F7(transform),
89− rotate:F2(rotate),
90− move:F2(move),
91− scale:F2(scale),
92− scaleX:F2(scaleX),
93− scaleY:F2(scaleY),
94− reflectX:reflectX,
95− reflectY:reflectY
96− */
97− };
98−
99−};
libraries/Native/Utils.jsdeleted−267
@@ -1,267 +0,0 @@
1−Elm.Native.Utils = {};
2−Elm.Native.Utils.make = function(elm) {
3−
4− elm.Native = elm.Native || {};
5− elm.Native.Utils = elm.Native.Utils || {};
6− if (elm.Native.Utils.values) return elm.Native.Utils.values;
7−
8− function eq(l,r) {
9− var stack = [{'x': l, 'y': r}]
10− while (stack.length > 0) {
11− var front = stack.pop();
12− var x = front.x;
13− var y = front.y;
14− if (x === y) continue;
15− if (typeof x === "object") {
16− var c = 0;
17− for (var i in x) {
18− ++c;
19− if (i in y) {
20− if (i !== 'ctor') {
21− stack.push({ 'x': x[i], 'y': y[i] });
22− }
23− } else {
24− return false;
25− }
26− }
27− if ('ctor' in x) {
28− stack.push({'x': x.ctor, 'y': y.ctor});
29− }
30− if (c !== Object.keys(y).length) {
31− return false;
32− };
33− } else if (typeof x === 'function') {
34− throw new Error('Equality error: general function equality is ' +
35− 'undecidable, and therefore, unsupported');
36− } else {
37− return false;
38− }
39− }
40− return true;
41− }
42−
43− // code in Generate/JavaScript.hs depends on the particular
44− // integer values assigned to LT, EQ, and GT
45− var LT = -1, EQ = 0, GT = 1, ord = ['LT','EQ','GT'];
46− function compare(x,y) { return { ctor: ord[cmp(x,y)+1] } }
47− function cmp(x,y) {
48− var ord;
49− if (typeof x !== 'object'){
50− return x === y ? EQ : x < y ? LT : GT;
51− }
52− else if (x.isChar){
53− var a = x.toString();
54− var b = y.toString();
55− return a === b ? EQ : a < b ? LT : GT;
56− }
57− else if (x.ctor === "::" || x.ctor === "[]") {
58− while (true) {
59− if (x.ctor === "[]" && y.ctor === "[]") return EQ;
60− if (x.ctor !== y.ctor) return x.ctor === '[]' ? LT : GT;
61− ord = cmp(x._0, y._0);
62− if (ord !== EQ) return ord;
63− x = x._1;
64− y = y._1;
65− }
66− }
67− else if (x.ctor.slice(0,6) === '_Tuple') {
68− var n = x.ctor.slice(6) - 0;
69− var err = 'cannot compare tuples with more than 6 elements.';
70− if (n === 0) return EQ;
71− if (n >= 1) { ord = cmp(x._0, y._0); if (ord !== EQ) return ord;
72− if (n >= 2) { ord = cmp(x._1, y._1); if (ord !== EQ) return ord;
73− if (n >= 3) { ord = cmp(x._2, y._2); if (ord !== EQ) return ord;
74− if (n >= 4) { ord = cmp(x._3, y._3); if (ord !== EQ) return ord;
75− if (n >= 5) { ord = cmp(x._4, y._4); if (ord !== EQ) return ord;
76− if (n >= 6) { ord = cmp(x._5, y._5); if (ord !== EQ) return ord;
77− if (n >= 7) throw new Error('Comparison error: ' + err); } } } } } }
78− return EQ;
79− }
80− else {
81− throw new Error('Comparison error: comparison is only defined on ints, ' +
82− 'floats, times, chars, strings, lists of comparable values, ' +
83− 'and tuples of comparable values.');
84− }
85− }
86−
87−
88− var Tuple0 = { ctor: "_Tuple0" };
89− function Tuple2(x,y) { return { ctor:"_Tuple2", _0:x, _1:y } }
90−
91− function chr(c) {
92− var x = new String(c);
93− x.isChar = true;
94− return x;
95− }
96−
97− function txt(str) {
98− var t = new String(str);
99− t.text = true;
100− return t;
101− }
102−
103− function makeText(text) {
104− var style = '';
105− var href = '';
106− while (true) {
107− if (text.style) {
108− style += text.style;
109− text = text.text;
110− continue;
111− }
112− if (text.href) {
113− href = text.href;
114− text = text.text;
115− continue;
116− }
117− if (href) text = '<a href="' + href + '">' + text + '</a>';
118− if (style) text = '<span style="' + style + '">' + text + '</span>';
119− return text;
120− }
121− }
122−
123− var count = 0;
124− function guid(_) { return count++ }
125−
126− function copy(oldRecord) {
127− var newRecord = {};
128− for (var key in oldRecord) {
129− var value = key === '_'
130− ? copy(oldRecord._)
131− : oldRecord[key]
132− ;
133− newRecord[key] = value;
134− }
135− return newRecord;
136− }
137−
138− function remove(key, oldRecord) {
139− var record = copy(oldRecord);
140− if (key in record._) {
141− record[key] = record._[key][0];
142− record._[key] = record._[key].slice(1);
143− if (record._[key].length === 0) {
144− delete record._[key];
145− }
146− } else {
147− delete record[key];
148− }
149− return record;
150− }
151−
152− function replace(keyValuePairs, oldRecord) {
153− var record = copy(oldRecord);
154− for (var i = keyValuePairs.length; i--; ) {
155− var pair = keyValuePairs[i];
156− record[pair[0]] = pair[1];
157− }
158− return record;
159− }
160−
161− function insert(key, value, oldRecord) {
162− var newRecord = copy(oldRecord);
163− if (key in newRecord) {
164− var values = newRecord._[key];
165− var copiedValues = values ? values.slice(0) : [];
166− newRecord._[key] = [newRecord[key]].concat(copiedValues);
167− }
168− newRecord[key] = value;
169− return newRecord;
170− }
171−
172− function max(a,b) { return a > b ? a : b }
173− function min(a,b) { return a < b ? a : b }
174−
175− function mod(a,b) {
176− if (b === 0) {
177− throw new Error("Cannot perform mod 0. Division by zero error.");
178− }
179− var r = a % b;
180− var m = a === 0 ? 0 : (b > 0 ? (a >= 0 ? r : r+b) : -mod(-a,-b));
181−
182− return m === b ? 0 : m;
183− }
184−
185− function htmlHeight(width, rawHtml) {
186− // create dummy node
187− var html = rawHtml.html;
188− var t = document.createElement('div');
189− t.innerHTML = html;
190− if (width > 0) { t.style.width = width + "px"; }
191− t.style.visibility = "hidden";
192− t.style.styleFloat = "left";
193− t.style.cssFloat = "left";
194−
195− document.body.appendChild(t);
196−
197− // insert interpolated values
198− var args = rawHtml.args;
199− var guid = rawHtml.guid;
200− for (var i = args.length; i--; ) {
201− var arg = args[i];
202− var span = document.getElementById('md-' + guid + '-' + i);
203− if (arg.isElement) {
204− span.style.width = arg.props.width + 'px';
205− span.style.height = arg.props.height + 'px';
206− } else {
207− span.innerHTML = arg;
208− }
209− }
210−
211− // get dimensions
212− var style = window.getComputedStyle(t, null);
213− var w = Math.ceil(style.getPropertyValue("width").slice(0,-2) - 0);
214− var h = Math.ceil(style.getPropertyValue("height").slice(0,-2) - 0);
215− document.body.removeChild(t);
216− return Tuple2(w,h);
217− }
218−
219− function getXY(e) {
220− var posx = 0;
221− var posy = 0;
222− if (e.pageX || e.pageY) {
223− posx = e.pageX;
224− posy = e.pageY;
225− } else if (e.clientX || e.clientY) {
226− posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
227− posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
228− }
229−
230− if (elm.display === ElmRuntime.Display.COMPONENT) {
231− var rect = elm.node.getBoundingClientRect();
232− var relx = rect.left + document.body.scrollLeft + document.documentElement.scrollLeft;
233− var rely = rect.top + document.body.scrollTop + document.documentElement.scrollTop;
234− // TODO: figure out if there is a way to avoid rounding here
235− posx = posx - Math.round(relx) - elm.node.clientLeft;
236− posy = posy - Math.round(rely) - elm.node.clientTop;
237− }
238− return Tuple2(posx, posy);
239− }
240−
241− function isJSArray(a) {
242− return a instanceof Array;
243− }
244−
245− return elm.Native.Utils.values = {
246− eq:eq,
247− cmp:cmp,
248− compare:F2(compare),
249− Tuple0:Tuple0,
250− Tuple2:Tuple2,
251− chr:chr,
252− txt:txt,
253− makeText:makeText,
254− copy: copy,
255− remove: remove,
256− replace: replace,
257− insert: insert,
258− guid: guid,
259− max : F2(max),
260− min : F2(min),
261− mod : F2(mod),
262− htmlHeight: F2(htmlHeight),
263− getXY: getXY,
264− isJSArray: isJSArray,
265− toFloat: function(x) { return +x; }
266− };
267−};
libraries/Random.elmdeleted−30
@@ -1,30 +0,0 @@
1−module Random where
2−
3−{-| Since the core of Elm is pure, randomness must be handled via signals.
4−
5−# Random Numbers
6−@docs range, float, floatList
7−-}
8−
9−import Signal (Signal)
10−import Native.Random
11−
12−{-| Given a range from low to high and a signal of values, this produces
13−a new signal that changes whenever the input signal changes. The new
14−values are random number between 'low' and 'high' inclusive.
15−-}
16−range : Int -> Int -> Signal a -> Signal Int
17−range = Native.Random.range
18−
19−{-| Produces a new signal that changes whenever the input signal changes.
20−The new values are random numbers in [0..1).
21−-}
22−float : Signal a -> Signal Float
23−float = Native.Random.float_
24−
25−{-| Produces a new signal of lists that changes whenever the input signal
26−changes. The input signal specifies the length of the random list. Each value is
27−a random number in [0..1).
28−-}
29−floatList : Signal Int -> Signal [Float]
30−floatList = Native.Random.floatList
libraries/Regex.elmdeleted−126
@@ -1,126 +0,0 @@
1−module Regex where
2−{-| A library for working with regular expressions. It uses [the
3−same kind of regular expressions accepted by JavaScript](https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions).
4−
5−# Create
6−@docs regex, escape, caseInsensitive
7−
8−# Helpful Data Structures
9−
10−These data structures are needed to help define functions like [`find`](#find)
11−and [`replace`](#replace).
12−
13−@docs HowMany, Match
14−
15−# Use
16−@docs contains, find, replace, split
17−
18−-}
19−
20−import Maybe (Maybe)
21−import Native.Regex
22−
23−data Regex = Regex
24−
25−{-| Escape strings to be regular expressions, making all special characters
26−safe. So `regex (escape "^a+")` will match exactly `"^a+"` instead of a series
27−of `a`&rsquo;s that start at the beginning of the line.
28−-}
29−escape : String -> String
30−escape = Native.Regex.escape
31−
32−{-| Create a Regex that matches patterns [as specified in JavaScript](https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#Writing_a_Regular_Expression_Pattern).
33−
34−Be careful to escape backslashes properly! For example, `"\w"` is escaping the
35−letter `w` which is probably not what you want. You probably want `"\\w"`
36−instead, which escapes the backslash.
37−-}
38−regex : String -> Regex
39−regex = Native.Regex.regex
40−
41−
42−{-| Make a regex case insensitive -}
43−caseInsensitive : Regex -> Regex
44−caseInsensitive = Native.Regex.caseInsensitive
45−
46−{-| Check to see if a Regex is contained in a string.
47−
48−```haskell
49− contains (regex "123") "12345" == True
50− contains (regex "b+") "aabbcc" == True
51−
52− contains (regex "789") "12345" == False
53− contains (regex "z+") "aabbcc" == False
54−```
55−-}
56−contains : Regex -> String -> Bool
57−contains = Native.Regex.contains
58−
59−{-| A `Match` represents all of the details about a particular match in a string.
60−Here are details on each field:
61−
62− * `match` &mdash; the full string of the match.
63− * `submatches` &mdash; a regex might have [subpatterns, surrounded by
64− parentheses](https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions#Using_Parenthesized_Substring_Matches).
65− If there are N subpatterns, there will be N elements in the `submatches` list.
66− Each submatch in this list is a `Maybe` because not all subpatterns may trigger.
67− For example, `(regex "(a+)|(b+)")` will either match many `a`&rsquo;s or
68− many `b`&rsquo;s, but never both.
69− * `index` &mdash; the index of the match in the original string.
70− * `number` &mdash; if you find many matches, you can think of each one
71− as being labeled with a `number` starting at one. So the first time you
72− find a match, that is match `number` one. Second time is match `number` two.
73− This is useful when paired with `replace All` if replacement is dependent on how
74− many times a pattern has appeared before.
75−-}
76−type Match = { match : String, submatches : [Maybe String], index : Int, number : Int }
77−
78−{-| `HowMany` is used to specify how many matches you want to make. So
79−`replace All` would replace every match, but `replace (AtMost 2)` would
80−replace at most two matches (i.e. zero, one, two, but never three or more).
81−-}
82−data HowMany = All | AtMost Int
83−
84−{-| Find matches in a string:
85−
86−```haskell
87− findTwoCommas = find (AtMost 2) (regex ",")
88−
89− -- map .index (findTwoCommas "a,b,c,d,e") == [1,3]
90− -- map .index (findTwoCommas "a b c d e") == []
91−
92− places = find All (regex "[oi]n a (\\w+)") "I am on a boat in a lake."
93−
94− -- map .match places == ["on a boat", "in a lake"]
95− -- map .submatches places == [ [Just "boat"], [Just "lake"] ]
96−```
97−-}
98−find : HowMany -> Regex -> String -> [Match]
99−find = Native.Regex.find
100−
101−{-| Replace matches. The function from `Match` to `String` lets
102−you use the details of a specific match when making replacements.
103−
104−```haskell
105− devowel = replace All (regex "[aeiou]") (\_ -> "")
106−
107− -- devowel "The quick brown fox" == "Th qck brwn fx"
108−
109− reverseWords = replace All (regex "\\w+") (\{match} -> String.reverse match)
110−
111− -- reverseWords "deliver mined parts" == "reviled denim strap"
112−```
113−-}
114−replace : HowMany -> Regex -> (Match -> String) -> String -> String
115−replace = Native.Regex.replace
116−
117−{-| Split a string, using the regex as the separator.
118−
119−```haskell
120− split (AtMost 1) (regex ",") "tom,99,90,85" == ["tom","99,90,85"]
121−
122− split All (regex ",") "a,b,c,d" == ["a","b","c","d"]
123−```
124−-}
125−split : HowMany -> Regex -> String -> [String]
126−split = Native.Regex.split
libraries/Set.elmdeleted−102
@@ -1,102 +0,0 @@
1−
2−module Set
3− ( Set
4− , empty, singleton, insert, remove
5− , member
6− , foldl, foldr, map
7− , filter, partition
8− , union, intersect, diff
9− , toList, fromList
10− ) where
11−
12−{-| A set of unique values. The values can be any comparable type. This
13−includes `Int`, `Float`, `Time`, `Char`, `String`, and tuples or lists
14−of comparable types.
15−
16−Insert, remove, and query operations all take *O(log n)* time.
17−
18−# Build
19−@docs empty, singleton, insert, remove
20−
21−# Query
22−@docs member
23−
24−# Combine
25−@docs union, intersect, diff
26−
27−# Lists
28−@docs toList, fromList
29−
30−# Transform
31−@docs map, foldl, foldr, filter, partition
32−
33−-}
34−
35−import Maybe (Maybe)
36−import Dict as Dict
37−import List as List
38−
39−type Set t = Dict.Dict t ()
40−
41−{-| Create an empty set. -}
42−empty : Set comparable
43−empty = Dict.empty
44−
45−{-| Create a set with one value. -}
46−singleton : comparable -> Set comparable
47−singleton k = Dict.singleton k ()
48−
49−{-| Insert a value into a set. -}
50−insert : comparable -> Set comparable -> Set comparable
51−insert k = Dict.insert k ()
52−
53−{-| Remove a value from a set. If the value is not found, no changes are made.
54−-}
55−remove : comparable -> Set comparable -> Set comparable
56−remove = Dict.remove
57−
58−{-| Determine if a value is in a set. -}
59−member : comparable -> Set comparable -> Bool
60−member = Dict.member
61−
62−{-| Get the union of two sets. Keep all values. -}
63−union : Set comparable -> Set comparable -> Set comparable
64−union = Dict.union
65−
66−{-| Get the intersection of two sets. Keeps values that appear in both sets. -}
67−intersect : Set comparable -> Set comparable -> Set comparable
68−intersect = Dict.intersect
69−
70−{-| Get the difference between the first set and the second. Keeps values
71−that do not appear in the second set. -}
72−diff : Set comparable -> Set comparable -> Set comparable
73−diff = Dict.diff
74−
75−{-| Convert a set into a list. -}
76−toList : Set comparable -> [comparable]
77−toList = Dict.keys
78−
79−{-| Convert a list into a set, removing any duplicates. -}
80−fromList : [comparable] -> Set comparable
81−fromList xs = List.foldl insert empty xs
82−
83−{-| Fold over the values in a set, in order from lowest to highest. -}
84−foldl : (comparable -> b -> b) -> b -> Set comparable -> b
85−foldl f b s = Dict.foldl (\k _ b -> f k b) b s
86−
87−{-| Fold over the values in a set, in order from highest to lowest. -}
88−foldr : (comparable -> b -> b) -> b -> Set comparable -> b
89−foldr f b s = Dict.foldr (\k _ b -> f k b) b s
90−
91−{-| Map a function onto a set, creating a new set with no duplicates. -}
92−map : (comparable -> comparable') -> Set comparable -> Set comparable'
93−map f s = fromList (List.map f (toList s))
94−
95−{-| Create a new set consisting only of elements which satisfy a predicate. -}
96−filter : (comparable -> Bool) -> Set comparable -> Set comparable
97−filter p set = Dict.filter (\k _ -> p k) set
98−
99−{-| Create two new sets; the first consisting of elements which satisfy a
100−predicate, the second consisting of elements which do not. -}
101−partition : (comparable -> Bool) -> Set comparable -> (Set comparable, Set comparable)
102−partition p set = Dict.partition (\k _ -> p k) set
libraries/Signal.elmdeleted−170
@@ -1,170 +0,0 @@
1−module Signal where
2−{-| The library for general signal manipulation. Includes lift functions up to
3−`lift8` and infix lift operators `<~` and `~`, combinations, filters, and
4−past-dependence.
5−
6−Signals are time-varying values. Lifted functions are reevaluated whenever any of
7−their input signals has an event. Signal events may be of the same value as the
8−previous value of the signal. Such signals are useful for timing and
9−past-dependence.
10−
11−Some useful functions for working with time (e.g. setting FPS) and combining
12−signals and time (e.g. delaying updates, getting timestamps) can be found in
13−the `Time` library.
14−
15−# Combine
16−@docs constant, lift, lift2, merge, merges, combine
17−
18−# Past-Dependence
19−@docs foldp, count, countIf
20−
21−#Filters
22−@docs keepIf, dropIf, keepWhen, dropWhen, dropRepeats, sampleOn
23−
24−# Pretty Lift
25−@docs (<~), (~)
26−
27−# Do you even lift?
28−@docs lift3, lift4, lift5, lift6, lift7, lift8
29−
30−-}
31−
32−import Native.Signal
33−import List (foldr, (::))
34−import Basics (fst, snd, not)
35−
36−data Signal a = Signal
37−
38−{-| Create a constant signal that never changes. -}
39−constant : a -> Signal a
40−constant = Native.Signal.constant
41−
42−{-| Transform a signal with a given function. -}
43−lift : (a -> b) -> Signal a -> Signal b
44−lift = Native.Signal.lift
45−
46−{-| Combine two signals with a given function. -}
47−lift2 : (a -> b -> c) -> Signal a -> Signal b -> Signal c
48−lift2 = Native.Signal.lift2
49−
50−lift3 : (a -> b -> c -> d) -> Signal a -> Signal b -> Signal c -> Signal d
51−lift3 = Native.Signal.lift3
52−
53−lift4 : (a -> b -> c -> d -> e) -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e
54−lift4 = Native.Signal.lift4
55−
56−lift5 : (a -> b -> c -> d -> e -> f) -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f
57−lift5 = Native.Signal.lift5
58−
59−lift6 : (a -> b -> c -> d -> e -> f -> g)
60− -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal g
61−lift6 = Native.Signal.lift6
62−
63−lift7 : (a -> b -> c -> d -> e -> f -> g -> h)
64− -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal g -> Signal h
65−lift7 = Native.Signal.lift7
66−
67−lift8 : (a -> b -> c -> d -> e -> f -> g -> h -> i)
68− -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal g -> Signal h -> Signal i
69−lift8 = Native.Signal.lift8
70−
71−
72−{-| Create a past-dependent signal. Each value given on the input signal will
73−be accumulated, producing a new output value.
74−
75−For instance, `foldp (+) 0 (fps 40)` is the time the program has been running,
76−updated 40 times a second. -}
77−foldp : (a -> b -> b) -> b -> Signal a -> Signal b
78−foldp = Native.Signal.foldp
79−
80−{-| Merge two signals into one, biased towards the first signal if both signals
81−update at the same time. -}
82−merge : Signal a -> Signal a -> Signal a
83−merge = Native.Signal.merge
84−
85−{-| Merge many signals into one, biased towards the left-most signal if multiple
86−signals update simultaneously. -}
87−merges : [Signal a] -> Signal a
88−merges = Native.Signal.merges
89−
90−{-| Combine a list of signals into a signal of lists. -}
91−combine : [Signal a] -> Signal [a]
92−combine = foldr (Native.Signal.lift2 (::)) (Native.Signal.constant [])
93−
94− -- Merge two signals into one, but distinguishing the values by marking the first
95− -- signal as `Left` and the second signal as `Right`. This allows you to easily
96− -- fold over non-homogeneous inputs.
97− -- mergeEither : Signal a -> Signal b -> Signal (Either a b)
98−
99−{-| Count the number of events that have occurred. -}
100−count : Signal a -> Signal Int
101−count = Native.Signal.count
102−
103−{-| Count the number of events that have occurred that satisfy a given predicate.
104−-}
105−countIf : (a -> Bool) -> Signal a -> Signal Int
106−countIf = Native.Signal.countIf
107−
108−{-| Keep only events that satisfy the given predicate. Elm does not allow
109−undefined signals, so a base case must be provided in case the predicate is
110−not satisfied initially. -}
111−keepIf : (a -> Bool) -> a -> Signal a -> Signal a
112−keepIf = Native.Signal.keepIf
113−
114−{-| Drop events that satisfy the given predicate. Elm does not allow undefined
115−signals, so a base case must be provided in case the predicate is satisfied
116−initially. -}
117−dropIf : (a -> Bool) -> a -> Signal a -> Signal a
118−dropIf = Native.Signal.dropIf
119−
120−{-| Keep events only when the first signal is true. Elm does not allow undefined
121−signals, so a base case must be provided in case the first signal is not true
122−initially.
123−-}
124−keepWhen : Signal Bool -> a -> Signal a -> Signal a
125−keepWhen bs def sig =
126− snd <~ (keepIf fst (False, def) ((,) <~ (sampleOn sig bs) ~ sig))
127−
128−{-| Drop events when the first signal is true. Elm does not allow undefined
129−signals, so a base case must be provided in case the first signal is true
130−initially.
131−-}
132−dropWhen : Signal Bool -> a -> Signal a -> Signal a
133−dropWhen bs = keepWhen (not <~ bs)
134−
135−{-| Drop updates that repeat the current value of the signal.
136−
137−Imagine a signal `numbers` has initial value
138−0 and then updates with values 0, 0, 1, 1, and 2. `dropRepeats numbers`
139−is a signal that has initial value 0 and updates as follows: ignore 0,
140−ignore 0, update to 1, ignore 1, update to 2. -}
141−dropRepeats : Signal a -> Signal a
142−dropRepeats = Native.Signal.dropRepeats
143−
144−{-| Sample from the second input every time an event occurs on the first input.
145−For example, `(sampleOn clicks (every second))` will give the approximate time
146−of the latest click. -}
147−sampleOn : Signal a -> Signal b -> Signal b
148−sampleOn = Native.Signal.sampleOn
149−
150−{-| An alias for `lift`. A prettier way to apply a function to the current value
151−of a signal. -}
152−(<~) : (a -> b) -> Signal a -> Signal b
153−f <~ s = Native.Signal.lift f s
154−
155−{-| Informally, an alias for `liftN`. Intersperse it between additional signal
156−arguments of the lifted function.
157−
158−Formally, signal application. This takes two signals, holding a function and
159−a value. It applies the current function to the current value.
160−
161−The following expressions are equivalent:
162−
163− scene <~ Window.dimensions ~ Mouse.position
164− lift2 scene Window.dimensions Mouse.position
165−-}
166−(~) : Signal (a -> b) -> Signal a -> Signal b
167−sf ~ s = Native.Signal.lift2 (\f x -> f x) sf s
168−
169−infixl 4 <~
170−infixl 4 ~
libraries/String.elmdeleted−340
@@ -1,340 +0,0 @@
1−module String where
2−{-| A built-in representation for efficient string manipulation. String literals
3−are enclosed in `"double quotes"`. Strings are *not* lists of characters.
4−
5−# Basics
6−@docs isEmpty, length, reverse, repeat
7−
8−# Building and Splitting
9−@docs cons, uncons, append, concat, split, join, words, lines
10−
11−# Get Substrings
12−@docs slice, left, right, dropLeft, dropRight
13−
14−# Check for Substrings
15−@docs contains, startsWith, endsWith, indexes, indices
16−
17−# Conversions
18−@docs show, toInt, toFloat, toList, fromList
19−
20−# Formatting
21−Cosmetic operations such as padding with extra characters or trimming whitespace.
22−
23−@docs toUpper, toLower,
24− pad, padLeft, padRight,
25− trim, trimLeft, trimRight
26−
27−# Higher-Order Functions
28−@docs map, filter, foldl, foldr, any, all
29−-}
30−
31−import Native.Show
32−import Native.String
33−import Maybe (Maybe)
34−
35−{-| Check if a string is empty.
36−
37− isEmpty "" == True
38− isEmpty "the world" == False
39−-}
40−isEmpty : String -> Bool
41−isEmpty = Native.String.isEmpty
42−
43−{-| Add a character to the beginning of a string -}
44−cons : Char -> String -> String
45−cons = Native.String.cons
46−
47−{-| Split a non-empty string into its head and tail. This lets you
48−pattern match on strings exactly as you would with lists.
49−
50− uncons "abc" == Just ('a',"bc")
51− uncons "" == Nothing
52−-}
53−uncons : String -> Maybe (Char, String)
54−uncons = Native.String.uncons
55−
56−{-| Append two strings. You can also use [the `(++)` operator](/library/List.elm#++)
57−to do this.
58−
59− append "butter" "fly" == "butterfly"
60−-}
61−append : String -> String -> String
62−append = Native.String.append
63−
64−{-| Concatenate many strings into one.
65−
66− concat ["never","the","less"] == "nevertheless"
67−-}
68−concat : [String] -> String
69−concat = Native.String.concat
70−
71−{-| Get the length of a string.
72−
73− length "innumerable" == 11
74− length "" == 0
75−
76−-}
77−length : String -> Int
78−length = Native.String.length
79−
80−{-| Transform every character in a string
81−
82− map (\c -> if c == '/' then '.' else c) "a/b/c" == "a.b.c"
83−-}
84−map : (Char -> Char) -> String -> String
85−map = Native.String.map
86−
87−{-| Keep only the characters that satisfy the predicate:
88−
89− filter isDigit "R2-D2" == "22"
90−-}
91−filter : (Char -> Bool) -> String -> String
92−filter = Native.String.filter
93−
94−{-| Reverse a string.
95−
96− reverse "stressed" == "desserts"
97−-}
98−reverse : String -> String
99−reverse = Native.String.reverse
100−
101−{-| Reduce a string from the left:
102−
103− foldl cons "" "time" == "emit"
104−-}
105−foldl : (Char -> b -> b) -> b -> String -> b
106−foldl = Native.String.foldl
107−
108−{-| Reduce a string from the right:
109−
110− foldr cons "" "time" == "time"
111−-}
112−foldr : (Char -> b -> b) -> b -> String -> b
113−foldr = Native.String.foldr
114−
115−{-| Split a string using a given separator.
116−
117− split "," "cat,dog,cow" == ["cat","dog","cow"]
118− split "/" "home/evan/Desktop/" == ["home","evan","Desktop", ""]
119−
120−Use `Regex.split` if you need something more flexible.
121−-}
122−split : String -> String -> [String]
123−split = Native.String.split
124−
125−{-| Put many strings together with a given separator.
126−
127− join "a" ["H","w","ii","n"] == "Hawaiian"
128− join " " ["cat","dog","cow"] == "cat dog cow"
129− join "/" ["home","evan","Desktop"] == "home/evan/Desktop"
130−-}
131−join : String -> [String] -> String
132−join = Native.String.join
133−
134−{-| Repeat a string N times.
135−
136− repeat 3 "ha" == "hahaha"
137−-}
138−repeat : Int -> String -> String
139−repeat = Native.String.repeat
140−
141−{-| Take a substring given a start and end index. Negative indexes
142−are taken starting from the *end* of the list.
143−
144− slice 7 9 "snakes on a plane!" == "on"
145− slice 0 6 "snakes on a plane!" == "snakes"
146− slice 0 -7 "snakes on a plane!" == "snakes on a"
147− slice -6 -1 "snakes on a plane!" == "plane"
148−-}
149−slice : Int -> Int -> String -> String
150−slice = Native.String.slice
151−
152−{-| Take N characters from the left side of a string. -}
153−left : Int -> String -> String
154−left = Native.String.left
155−
156−{-| Take N characters from the right side of a string. -}
157−right : Int -> String -> String
158−right = Native.String.right
159−
160−{-| Drop N characters from the left side of a string. -}
161−dropLeft : Int -> String -> String
162−dropLeft = Native.String.dropLeft
163−
164−{-| Drop N characters from the right side of a string. -}
165−dropRight : Int -> String -> String
166−dropRight = Native.String.dropRight
167−
168−{-| Pad a string on both sides until it has a given length.
169−
170− pad 5 ' ' "1" == " 1 "
171− pad 5 ' ' "11" == " 11 "
172− pad 5 ' ' "121" == " 121 "
173−-}
174−pad : Int -> Char -> String -> String
175−pad = Native.String.pad
176−
177−{-| Pad a string on the left until it has a given length.
178−
179− padLeft 5 '.' "1" == "....1"
180− padLeft 5 '.' "11" == "...11"
181− padLeft 5 '.' "121" == "..121"
182−-}
183−padLeft : Int -> Char -> String -> String
184−padLeft = Native.String.padLeft
185−
186−{-| Pad a string on the right until it has a given length.
187−
188− padRight 5 '.' "1" == "1...."
189− padRight 5 '.' "11" == "11..."
190− padRight 5 '.' "121" == "121.."
191−-}
192−padRight : Int -> Char -> String -> String
193−padRight = Native.String.padRight
194−
195−{-| Get rid of whitespace on both sides of a string.
196−
197− trim " hats \n" == "hats"
198−-}
199−trim : String -> String
200−trim = Native.String.trim
201−
202−{-| Get rid of whitespace on the left of a string.
203−
204− trimLeft " hats \n" == "hats \n"
205−-}
206−trimLeft : String -> String
207−trimLeft = Native.String.trimLeft
208−
209−{-| Get rid of whitespace on the right of a string.
210−
211− trimRight " hats \n" == " hats"
212−-}
213−trimRight : String -> String
214−trimRight = Native.String.trimRight
215−
216−{-| Break a string into words, splitting on chunks of whitespace.
217−
218− words "How are \t you? \n Good?" == ["How","are","you?","Good?"]
219−-}
220−words : String -> [String]
221−words = Native.String.words
222−
223−{-| Break a string into lines, splitting on newlines.
224−
225− lines "How are you?\nGood?" == ["How are you?", "Good?"]
226−-}
227−lines : String -> [String]
228−lines = Native.String.lines
229−
230−{-| Convert a string to all upper case. Useful for case insensitive comparisons
231−and VIRTUAL YELLING.
232−-}
233−toUpper : String -> String
234−toUpper = Native.String.toUpper
235−
236−{-| Convert a string to all lower case. Useful for case insensitive comparisons. -}
237−toLower : String -> String
238−toLower = Native.String.toLower
239−
240−{-| Check to see if *any* characters satisfy a predicate.
241−
242− any isDigit "90210" == True
243− any isDigit "R2-D2" == True
244− any isDigit "heart" == False
245−-}
246−any : (Char -> Bool) -> String -> Bool
247−any = Native.String.any
248−
249−{-| Check to see if *all* characters satisfy a predicate.
250−
251− all isDigit "90210" == True
252− all isDigit "R2-D2" == False
253− all isDigit "heart" == False
254−-}
255−all : (Char -> Bool) -> String -> Bool
256−all = Native.String.all
257−
258−{-| See if the second string contains the first one.
259−
260− contains "the" "theory" == True
261− contains "hat" "theory" == False
262− contains "THE" "theory" == False
263−
264−Use `Regex.contains` if you need something more flexible.
265−-}
266−contains : String -> String -> Bool
267−contains = Native.String.contains
268−
269−{-| See if the second string starts with the first one.
270−
271− startsWith "the" "theory" == True
272− startsWith "ory" "theory" == False
273−-}
274−startsWith : String -> String -> Bool
275−startsWith = Native.String.startsWith
276−
277−{-| See if the second string ends with the first one.
278−
279− endsWith "the" "theory" == False
280− endsWith "ory" "theory" == True
281−-}
282−endsWith : String -> String -> Bool
283−endsWith = Native.String.endsWith
284−
285−{-| Get all of the indexes for a substring in another string.
286−
287− indexes "i" "Mississippi" == [1,4,7,10]
288− indexes "ss" "Mississippi" == [2,5]
289− indexes "needle" "haystack" == []
290−-}
291−indexes : String -> String -> [Int]
292−indexes = Native.String.indexes
293−
294−{-| Alias for `indexes` -}
295−indices : String -> String -> [Int]
296−indices = Native.String.indexes
297−
298−{-| Turn any kind of value into a string.
299−
300− show 42 == "42"
301− show [1,2] == "[1,2]"
302−-}
303−show : a -> String
304−show = Native.Show.show
305−
306−{-| Try to convert a string into an int, failing on improperly formatted strings.
307−
308− toInt "123" == Just 123
309− toInt "-42" == Just -42
310− toInt "3.1" == Nothing
311− toInt "31a" == Nothing
312−-}
313−toInt : String -> Maybe Int
314−toInt = Native.String.toInt
315−
316−{-| Try to convert a string into a float, failing on improperly formatted strings.
317−
318− toFloat "123" == Just 123.0
319− toFloat "-42" == Just -42.0
320− toFloat "3.1" == Just 3.1
321− toFloat "31a" == Nothing
322−-}
323−toFloat : String -> Maybe Float
324−toFloat = Native.String.toFloat
325−
326−{-| Convert a string to a list of characters.
327−
328− toList "abc" == ['a','b','c']
329−-}
330−toList : String -> [Char]
331−toList = Native.String.toList
332−
333−{-| Convert a list of characters into a String. Can be useful if you
334−want to create a string primarly by consing, perhaps for decoding
335−something.
336−
337− fromList ['a','b','c'] == "abc"
338−-}
339−fromList : [Char] -> String
340−fromList = Native.String.fromList
libraries/Text.elmdeleted−221
@@ -1,221 +0,0 @@
1−module Text where
2−{-| A library for styling and displaying text. Whlie the `String` library
3−focuses on representing and manipulating strings of character strings, the
4−`Text` library focuses on how those strings should look on screen. It lets
5−you make text bold or italic, set the typeface, set the text size, etc.
6−
7−# Creating Text
8−@docs toText
9−
10−# Creating Elements
11−
12−Each of the following functions places `Text` into a box. The function you use
13−determines the alignment of the text.
14−
15−@docs leftAligned, rightAligned, centered, justified
16−
17−# Links and Style
18−@docs link, Style, style, defaultStyle, Line
19−
20−# Convenience Functions
21−
22−There are two convenience functions for creating an `Element` which can be
23−useful when debugging or prototyping:
24−
25−@docs plainText, asText
26−
27−There are also a bunch of functions to set parts of a `Style` individually:
28−
29−@docs typeface, monospace, height, color, bold, italic, line
30−
31−-}
32−
33−import Basics (..)
34−import String
35−import Color (Color, black)
36−import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
37−import Maybe (Maybe(Nothing))
38−import Native.Show
39−import Native.Text
40−
41−data Text = Text
42−
43−{-| Styles for lines on text. This allows you to add an underline, an overline,
44−or a strike out text:
45−
46− line Under (toText "underline")
47− line Over (toText "overline")
48− line Through (toText "strike out")
49−-}
50−data Line = Under | Over | Through
51−
52−{-| Representation of all the ways you can style `Text`. If the `typeface` list
53−is empty or the `height` is `Nothing`, the users will fall back on their
54−browser's default settings. The following `Style` is black, 16 pixel tall,
55−underlined, and Times New Roman (assuming that typeface is available on the
56−user's computer):
57−
58− { typeface = [ "Times New Roman", "serif" ]
59− , height = Just 16
60− , color = black
61− , bold = False
62− , italic = False
63− , line = Just Under
64− }
65−-}
66−type Style =
67− { typeface : [String]
68− , height : Maybe Float
69− , color : Color
70− , bold : Bool
71− , italic : Bool
72− , line : Maybe Line
73− }
74−
75−{-| Plain black text. It uses the browsers default typeface and text height.
76−No decorations are used:
77−
78− { typeface = []
79− , height = Nothing
80− , color = black
81− , bold = False
82− , italic = False
83− , line = Nothing
84− }
85−-}
86−defaultStyle : Style
87−defaultStyle =
88− { typeface = []
89− , height = Nothing
90− , color = black
91− , bold = False
92− , italic = False
93− , line = Nothing
94− }
95−
96−{-| Convert a string into text which can be styled and displayed. To show the
97−string `"Hello World!"` on screen in italics, you could say:
98−
99− main = leftAligned (italic (toText "Hello World!"))
100−-}
101−toText : String -> Text
102−toText = Native.Text.toText
103−
104−{-| Set the style of some text. For example, if you design a `Style` called
105−`footerStyle` that is specifically for the bottom of your page, you could apply
106−it to text like this:
107−
108− style footerStyle (toText "the old prince / 2007")
109−-}
110−style : Style -> Text -> Text
111−style = Native.Text.style
112−
113−{-| Provide a list of prefered typefaces for some text.
114−
115− ["helvetica","arial","sans-serif"]
116−
117−Not every browser has access to the same typefaces, so rendering will use the
118−first typeface in the list that is found on the user's computer. If there are
119−no matches, it will use their default typeface. This works the same as the CSS
120−font-family property.
121−-}
122−typeface : [String] -> Text -> Text
123−typeface = Native.Text.typeface
124−
125−{-| Switch to a monospace typeface. Good for code snippets.
126−
127− monospace (toText "foldl (+) 0 [1,2,3]")
128−-}
129−monospace : Text -> Text
130−monospace = Native.Text.monospace
131−
132−{-| Create a link by providing a URL and the text of the link:
133−
134− link "http://elm-lang.org" (toText "Elm Website")
135−-}
136−link : String -> Text -> Text
137−link = Native.Text.link
138−
139−{-| Set the height of some text:
140−
141− height 40 (toText "Title")
142−-}
143−height : Float -> Text -> Text
144−height = Native.Text.height
145−
146−{-| Set the color of some text:
147−
148− color red (toText "Red")
149−-}
150−color : Color -> Text -> Text
151−color = Native.Text.color
152−
153−{-| Make text bold:
154−
155− toText "sometimes you want " ++ bold (toText "emphasis")
156−-}
157−bold : Text -> Text
158−bold = Native.Text.bold
159−
160−{-| Make text italic:
161−
162− toText "make it " ++ italic (toText "important")
163−-}
164−italic : Text -> Text
165−italic = Native.Text.italic
166−
167−{-| Put lines on text:
168−
169− line Under (toText "underlined")
170− line Over (toText "overlined")
171− line Through (toText "strike out")
172−-}
173−line : Line -> Text -> Text
174−line = Native.Text.line
175−
176−{-| `Text` is aligned along the left side of the text block. This is sometimes
177−known as *ragged right*.
178−-}
179−leftAligned : Text -> Element
180−leftAligned = Native.Text.leftAligned
181−
182−{-| `Text` is aligned along the right side of the text block. This is sometimes
183−known as *ragged left*.
184−-}
185−rightAligned : Text -> Element
186−rightAligned = Native.Text.rightAligned
187−
188−{-| `Text` is centered in the text block. There is equal spacing on either side
189−of a line of text.
190−-}
191−centered : Text -> Element
192−centered = Native.Text.centered
193−
194−{-| `Text` is aligned along the left and right sides of the text block. Word
195−spacing is adjusted to make this possible.
196−-}
197−justified : Text -> Element
198−justified = Native.Text.justified
199−
200−{-| Display a string with no styling:
201−
202− plainText string = leftAligned (toText string)
203−-}
204−plainText : String -> Element
205−plainText str =
206− leftAligned (toText str)
207−
208−{-| for internal use only -}
209−markdown : Element
210−markdown = Native.Text.markdown
211−
212−{-| Convert anything to its textual representation and make it displayable in
213−the browser:
214−
215− asText value = leftAligned (monospace (toText (show value)))
216−
217−Excellent for debugging.
218−-}
219−asText : a -> Element
220−asText value =
221− leftAligned (monospace (toText (Native.Show.show value)))
libraries/Time.elmdeleted−99
@@ -1,99 +0,0 @@
1−module Time where
2−
3−{-| Library for working with time.
4−
5−# Units
6−@docs Time, millisecond, second, minute, hour,
7− inMilliseconds, inSeconds, inMinutes, inHours
8−
9−# Tickers
10−@docs fps, fpsWhen, every
11−
12−# Timing
13−@docs timestamp, delay, since
14−
15−-}
16−
17−import Basics (..)
18−import Native.Time
19−import Signal (Signal)
20−
21−{-| Type alias to make it clearer when you are working with time values.
22−Using the `Time` constants instead of raw numbers is very highly recommended.
23−-}
24−type Time = Float
25−
26−{-| Units of time, making it easier to specify things like a half-second
27−`(500 * milliseconds)` without remembering Elm&rsquo;s underlying units of time.
28−-}
29−millisecond : Time
30−millisecond = 1
31−
32−second : Time
33−second = 1000 * millisecond
34−
35−minute : Time
36−minute = 60 * second
37−
38−hour : Time
39−hour = 60 * minute
40−
41−inMilliseconds : Time -> Float
42−inMilliseconds t = t
43−
44−inSeconds : Time -> Float
45−inSeconds t = t / second
46−
47−inMinutes : Time -> Float
48−inMinutes t = t / minute
49−
50−inHours : Time -> Float
51−inHours t = t / hour
52−
53−{-| Takes desired number of frames per second (fps). The resulting signal
54−gives a sequence of time deltas as quickly as possible until it reaches
55−the desired FPS. A time delta is the time between the last frame and the
56−current frame.
57−-}
58−fps : number -> Signal Time
59−fps = Native.Time.fps
60−
61−{-| Same as the fps function, but you can turn it on and off. Allows you
62−to do brief animations based on user input without major inefficiencies.
63−The first time delta after a pause is always zero, no matter how long
64−the pause was. This way summing the deltas will actually give the amount
65−of time that the output signal has been running.
66−-}
67−fpsWhen : number -> Signal Bool -> Signal Time
68−fpsWhen = Native.Time.fpsWhen
69−
70−{-| Takes a time interval t. The resulting signal is the current time, updated
71−every t.
72−-}
73−every : Time -> Signal Time
74−every = Native.Time.every
75−
76−{-| Takes a time `t` and any signal. The resulting boolean signal is true for
77−time `t` after every event on the input signal. So ``(second `since`
78−Mouse.clicks)`` would result in a signal that is true for one second after
79−each mouse click and false otherwise.
80−-}
81−since : Time -> Signal a -> Signal Bool
82−since = Native.Time.since
83−
84−{-| Add a timestamp to any signal. Timestamps increase monotonically. When you
85−create `(timestamp Mouse.x)`, an initial timestamp is produced. The timestamp
86−updates whenever `Mouse.x` updates.
87−
88−Timestamp updates are tied to individual events, so
89−`(timestamp Mouse.x)` and `(timestamp Mouse.y)` will always have the same
90−timestamp because they rely on the same underlying event (`Mouse.position`).
91−-}
92−timestamp : Signal a -> Signal (Time, a)
93−timestamp = Native.Time.timestamp
94−
95−{-| Delay a signal by a certain amount of time. So `(delay second Mouse.clicks)`
96−will update one second later than any mouse click.
97−-}
98−delay : Time -> Signal a -> Signal a
99−delay = Native.Time.delay
libraries/Touch.elmdeleted−34
@@ -1,34 +0,0 @@
1−module Touch where
2−
3−{-| This is an early version of the touch library. It will likely grow to
4−include gestures that would be useful for both games and web-pages.
5−
6−# Touches
7−@docs Touch, touches
8−
9−# Gestures
10−@docs taps
11−-}
12−
13−import Signal (Signal)
14−import Native.Touch
15−import Time (Time)
16−
17−{-| Every `Touch` has `xy` coordinates. It also has an identifier
18−`id` to distinguish one touch from another.
19−
20−A touch also keeps info about the initial point and time of contact:
21−`x0`, `y0`, and `t0`. This helps compute more complicated gestures
22−like taps, drags, and swipes which need to know about timing or direction.
23−-}
24−type Touch = { x:Int, y:Int, id:Int, x0:Int, y0:Int, t0:Time }
25−
26−{-| A list of ongoing touches. -}
27−touches : Signal [Touch]
28−touches = Native.Touch.touches
29−
30−{-| The last position that was tapped. Default value is `{x=0,y=0}`.
31−Updates whenever the user taps the screen.
32−-}
33−taps : Signal { x:Int, y:Int }
34−taps = Native.Touch.taps
libraries/Trampoline.elmdeleted−49
@@ -1,49 +0,0 @@
1−module Trampoline where
2−{-| A [trampoline](http://en.wikipedia.org/wiki/Tail-recursive_function#Through_trampolining)
3−makes it possible to recursively call a function without growing the stack.
4−
5−Popular JavaScript implementations do not perform any tail-call elimination, so
6−recursive functions can cause a stack overflow if they go to deep. Trampolines
7−permit unbounded recursion despite limitations in JavaScript.
8−
9−This strategy may create many intermediate closures, which is very expensive in
10−JavaScript, so use this library only when it is essential that you recurse deeply.
11−
12−# Trampolines
13−@docs trampoline, Trampoline
14−-}
15−
16−import Native.Trampoline
17−
18−{-| A way to build computations that may be deeply recursive. We will take an
19−example of a tail-recursive function and rewrite it in a way that lets us use
20−a trampoline:
21−
22− length : [a] -> Int
23− length list = length' 0 list
24−
25− length' : Int -> [a] -> Int
26− length' accum list =
27− case list of
28− [] -> accum
29− hd::tl -> length' (accum+1) tl
30−
31−This finds the length of a list, but if the list is too long, it may cause a
32−stack overflow. We can rewrite it as follows:
33−
34− length : [a] -> Int
35− length list = trampoline (length' 0 list)
36−
37− length' : Int -> [a] -> Trampoline Int
38− length' accum list =
39− case list of
40− [] -> Done accum
41− hd::tl -> Continue (\() -> length' (accum+1) tl)
42−
43−Now it uses a trampoline and can recurse without growing the stack!
44−-}
45−data Trampoline a = Done a | Continue (() -> Trampoline a)
46−
47−{-| Evaluate a trampolined value in constant space. -}
48−trampoline : Trampoline a -> a
49−trampoline = Native.Trampoline.trampoline
libraries/Transform2D.elmdeleted−96
@@ -1,96 +0,0 @@
1−module Transform2D ( Transform2D
2− , identity, matrix, multiply
3− , rotation, translation
4− , scale, scaleX, scaleY
5− ) where
6−{-| A library for performing [2D matrix transformations][affine].
7−It is used primarily with the `groupTransform` function from `Graphics.Collage` and
8−allows you to do things like rotation, scaling, translation, shearing, and reflection.
9−
10−Note that all the matrices in this library are 3x3 matrices of homogeneous
11−coordinates, used for [affine transformations][affine]. Since the bottom row as
12−always `0 0 1` in these matrices, it is omitted in the diagrams below.
13−
14− [affine]: http://en.wikipedia.org/wiki/Transformation_matrix#Affine_transformations
15−
16−# Transforms
17−@docs identity, matrix, rotation, translation, scale, scaleX, scaleY
18−
19−# Multiplication
20−@docs multiply
21−-}
22−
23−import Native.Transform2D
24−
25−data Transform2D = Transform2D
26−
27−{-| Create an identity transform. Transforming by the identity does
28−not change anything, but it can come in handy as a default or
29−base case.
30−
31− / 1 0 0 \
32− \ 0 1 0 /
33−-}
34−identity : Transform2D
35−identity = Native.Transform2D.identity
36−
37−{-| Creates a transformation matrix. This lets you create transforms
38−such as scales, shears, reflections, and translations.
39−
40− matrix a b c d x y
41−
42− / a b x \
43− \ c d y /
44−
45−Note that `x` and `y` are the translation values.
46−-}
47−matrix : Float -> Float -> Float -> Float -> Float -> Float -> Transform2D
48−matrix = Native.Transform2D.matrix
49−
50−{-| Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
51−Given an angle t, it creates a counterclockwise rotation matrix:
52−
53− / cos t -sin t 0 \
54− \ sin t cos t 0 /
55−-}
56−rotation : Float -> Transform2D
57−rotation = Native.Transform2D.rotation
58−
59−{-| Creates a transformation matrix for translation:
60−
61− translation x y
62−
63− / 1 0 x \
64− \ 0 1 y /
65−-}
66−translation : Float -> Float -> Transform2D
67−translation x y = matrix 1 0 0 1 x y
68−
69−{-| Creates a transformation matrix for scaling by a all directions:
70−
71− scale s
72−
73− / s 0 0 \
74− \ 0 s 0 /
75−-}
76−scale : Float -> Transform2D
77−scale s = matrix s 0 0 s 0 0
78−
79−{-| Creates a transformation for horizontal scaling -}
80−scaleX : Float -> Transform2D
81−scaleX x = matrix x 0 0 1 0 0
82−
83−{-| Creates a transformation for vertical scaling -}
84−scaleY : Float -> Transform2D
85−scaleY y = matrix 1 0 0 y 0 0
86−
87−{-| Multiplies two transforms together:
88−
89− multiply m n
90−
91− / ma mb mx \ / na nb nx \
92− | mc md my | . | nc nd ny |
93− \ 0 0 1 / \ 0 0 1 /
94−-}
95−multiply : Transform2D -> Transform2D -> Transform2D
96−multiply = Native.Transform2D.multiply
libraries/WebSocket.elmdeleted−21
@@ -1,21 +0,0 @@
1−module WebSocket where
2−{-| A library for low latency HTTP communication. See the HTTP library for
3−standard requests like GET, POST, etc. The API of this library is likely to
4−change to make it more flexible.
5−
6−# Open a Connection
7−@docs connect
8−-}
9−
10−import Signal (Signal)
11−import Native.WebSocket
12−
13−{-| Create a web-socket. The first argument is the URL of the desired
14−web-socket server. The input signal holds the outgoing messages,
15−and the resulting signal contains the incoming ones.
16−-}
17−connect : String -> Signal String -> Signal String
18−connect = Native.WebSocket.connect
19−
20−-- data Action = Open String | Close String | Send String String
21−-- connections : Signal Action -> Signal String
libraries/Window.elmdeleted−27
@@ -1,27 +0,0 @@
1−
2−module Window where
3−
4−{-| Provides information about the container that your Elm program lives in.
5−When you embed Elm in a `<div>` it gives the dimensions of the container, not
6−the whole window.
7−
8−# Dimensions
9−@docs dimensions, width, height
10−
11−-}
12−
13−import Signal (Signal)
14−import Native.Window
15−
16−{-| The current width and height of the window (i.e. the area viewable to the
17−user, not including scroll bars). -}
18−dimensions : Signal (Int,Int)
19−dimensions = Native.Window.dimensions
20−
21−{-| The current width of the window. -}
22−width : Signal Int
23−width = Native.Window.width
24−
25−{-| The current height of the window. -}
26−height : Signal Int
27−height = Native.Window.height
libraries/elm_dependencies.jsondeleted−42
@@ -1,42 +0,0 @@
1−{ "version": "0.13"
2−, "summary": "Elm's standard libraries"
3−, "description": "The full set of standard libraries for Elm. This library is pegged to the version number of the compiler, so if you are using Elm 0.13, you should be using version 0.13 of the standard libraries."
4−, "license": "BSD3"
5−, "repository": "http://github.com/elm-lang/Elm.git"
6−, "elm-version": "0.13"
7−, "dependencies": {}
8−, "exposed-modules":
9− [ "Array"
10− , "Basics"
11− , "Bitwise"
12− , "Char"
13− , "Color"
14− , "Date"
15− , "Debug"
16− , "Dict"
17− , "Either"
18− , "Graphics.Element"
19− , "Graphics.Collage"
20− , "Graphics.Input"
21− , "Graphics.Input.Field"
22− , "Http"
23− , "JavaScript.Experimental"
24− , "Json"
25− , "Keyboard"
26− , "List"
27− , "Maybe"
28− , "Mouse"
29− , "Random"
30− , "Regex"
31− , "Set"
32− , "Signal"
33− , "String"
34− , "Text"
35− , "Time"
36− , "Touch"
37− , "Trampoline"
38− , "Transform2D"
39− , "WebSocket"
40− , "Window"
41− ]
42−}