on master help sign in
Fix libraries to match new JS generation rules
3e4773cEvan Czaplicki
libraries/Basics.elm+51−51
@@ -1,7 +1,7 @@
1
1
2module Basics where
2module Basics where
3
3
4−import Native.Basics as Native
4+import Native.Basics
5
5
6type String = [Char]
6type String = [Char]
7
7
@@ -11,72 +11,72 @@ radians t = t
11
11
12-- Convert degrees to standard Elm angles (radians).
12-- Convert degrees to standard Elm angles (radians).
13degrees : Float -> Float
13degrees : Float -> Float
14−degrees d = d * Native.pi / 180
14+degrees d = d * Native.Basics.pi / 180
15
15
16-- Convert turns to standard Elm angles (radians).
16-- Convert turns to standard Elm angles (radians).
17-- One turn is equal to 360°.
17-- One turn is equal to 360°.
18turns : Float -> Float
18turns : Float -> Float
19−turns r = 2 * Native.pi * r
19+turns r = 2 * Native.Basics.pi * r
20
20
21-- Start with polar coordinates (r,θ)
21-- Start with polar coordinates (r,θ)
22-- and get out cartesian coordinates (x,y).
22-- and get out cartesian coordinates (x,y).
23fromPolar : (Float,Float) -> (Float,Float)
23fromPolar : (Float,Float) -> (Float,Float)
24−fromPolar (r,t) = (r * Native.cos t, r * Native.sin t)
24+fromPolar (r,t) = (r * Native.Basics.cos t, r * Native.Basics.sin t)
25
25
26-- Start with cartesian coordinates (x,y)
26-- Start with cartesian coordinates (x,y)
27-- and get out polar coordinates (r,θ).
27-- and get out polar coordinates (r,θ).
28toPolar : (Float,Float) -> (Float,Float)
28toPolar : (Float,Float) -> (Float,Float)
29−toPolar (x,y) = (Native.sqrt (x^2 + y^2), Native.atan2 y x)
29+toPolar (x,y) = (Native.Basics.sqrt (x^2 + y^2), Native.Basics.atan2 y x)
30
30
31(+) : number -> number -> number
31(+) : number -> number -> number
32−(+) = Native.add
32+(+) = Native.Basics.add
33
33
34(-) : number -> number -> number
34(-) : number -> number -> number
35−(-) = Native.sub
35+(-) = Native.Basics.sub
36
36
37(*) : number -> number -> number
37(*) : number -> number -> number
38−(*) = Native.mul
38+(*) = Native.Basics.mul
39
39
40-- Floating point division.
40-- Floating point division.
41(/) : Float -> Float -> Float
41(/) : Float -> Float -> Float
42−(/) = Native.floatDiv
42+(/) = Native.Basics.floatDiv
43
43
44-- Integer division, remainder is discarded.
44-- Integer division, remainder is discarded.
45div : Int -> Int -> Int
45div : Int -> Int -> Int
46−div = Native.div
46+div = Native.Basics.div
47
47
48-- Finds the remainder after dividing one number by another: ``4 `rem` 3 == 1``
48-- Finds the remainder after dividing one number by another: ``4 `rem` 3 == 1``
49rem : Int -> Int -> Int
49rem : Int -> Int -> Int
50−rem = Native.rem
50+rem = Native.Basics.rem
51
51
52-- Perform modular arithmetic: ``7 `mod` 2 == 1``
52-- Perform modular arithmetic: ``7 `mod` 2 == 1``
53mod : Int -> Int -> Int
53mod : Int -> Int -> Int
54−mod = Native.mod
54+mod = Native.Basics.mod
55
55
56-- Exponentiation: `3^2 == 9`
56-- Exponentiation: `3^2 == 9`
57(^) : number -> number -> number
57(^) : number -> number -> number
58−(^) = Native.exp
58+(^) = Native.Basics.exp
59
59
60cos : Float -> Float
60cos : Float -> Float
61−cos = Native.cos
61+cos = Native.Basics.cos
62
62
63sin : Float -> Float
63sin : Float -> Float
64−sin = Native.sin
64+sin = Native.Basics.sin
65
65
66tan : Float -> Float
66tan : Float -> Float
67−tan = Native.tan
67+tan = Native.Basics.tan
68
68
69acos : Float -> Float
69acos : Float -> Float
70−acos = Native.acos
70+acos = Native.Basics.acos
71
71
72asin : Float -> Float
72asin : Float -> Float
73−asin = Native.asin
73+asin = Native.Basics.asin
74
74
75-- You probably do not want to use this. Because it takes `(y/x)` as the argument
75-- You probably do not want to use this. Because it takes `(y/x)` as the argument
76-- there is no way to know where the negative signs come from so the resulting
76-- there is no way to know where the negative signs come from so the resulting
77-- angle is always between π/2 and -π/2 (in quadrants I and IV).
77-- angle is always between π/2 and -π/2 (in quadrants I and IV).
78atan : Float -> Float
78atan : Float -> Float
79−atan = Native.atan
79+atan = Native.Basics.atan
80
80
81-- This helps you find the angle of a cartesian coordinate.
81-- This helps you find the angle of a cartesian coordinate.
82-- You will almost certainly want to use this instead of `atan`.
82-- You will almost certainly want to use this instead of `atan`.
@@ -84,27 +84,27 @@ atan = Native.atan
84-- quadrant the angle should really be in. The result will be between
84-- quadrant the angle should really be in. The result will be between
85-- π and -π, giving you the full range of angles.
85-- π and -π, giving you the full range of angles.
86atan2 : Float -> Float -> Float
86atan2 : Float -> Float -> Float
87−atan2 = Native.atan2
87+atan2 = Native.Basics.atan2
88
88
89-- Take the square root of a number.
89-- Take the square root of a number.
90sqrt : number -> number
90sqrt : number -> number
91−sqrt = Native.sqrt
91+sqrt = Native.Basics.sqrt
92
92
93-- Take the absolute value of a number.
93-- Take the absolute value of a number.
94abs : number -> number
94abs : number -> number
95−abs = Native.abs
95+abs = Native.Basics.abs
96
96
97-- Calculate the logarithm of a number with a given base: `logBase 10 100 == 2`
97-- Calculate the logarithm of a number with a given base: `logBase 10 100 == 2`
98logBase : number -> number -> number
98logBase : number -> number -> number
99−logBase = Native.logBase
99+logBase = Native.Basics.logBase
100
100
101-- Given two comparables, returns the smaller one.
101-- Given two comparables, returns the smaller one.
102min : comparable -> comparable -> comparable
102min : comparable -> comparable -> comparable
103−min = Native.min
103+min = Native.Basics.min
104
104
105-- Given two comparables, returns the larger one.
105-- Given two comparables, returns the larger one.
106max : comparable -> comparable -> comparable
106max : comparable -> comparable -> comparable
107−max = Native.max
107+max = Native.Basics.max
108
108
109-- Clamps a number within a given range. With the expression `clamp 100 200 x`
109-- Clamps a number within a given range. With the expression `clamp 100 200 x`
110-- the results are as follows:
110-- the results are as follows:
@@ -113,40 +113,40 @@ max = Native.max
113-- * ` x if 100 <= x < 200`
113-- * ` x if 100 <= x < 200`
114-- * `200 if 200 <= x`
114-- * `200 if 200 <= x`
115clamp : number -> number -> number -> number
115clamp : number -> number -> number -> number
116−clamp = Native.clamp
116+clamp = Native.Basics.clamp
117
117
118-- An approximation of pi.
118-- An approximation of pi.
119pi : Float
119pi : Float
120−pi = Native.pi
120+pi = Native.Basics.pi
121
121
122-- An approximation of e.
122-- An approximation of e.
123e : Float
123e : Float
124−e = Native.e
124+e = Native.Basics.e
125
125
126-- Compare any two values for structural equality. Functions cannot be compared.
126-- Compare any two values for structural equality. Functions cannot be compared.
127(==) : a -> a -> Bool
127(==) : a -> a -> Bool
128−(==) = Native.eq
128+(==) = Native.Basics.eq
129
129
130(/=) : a -> a -> Bool
130(/=) : a -> a -> Bool
131−(/=) = Native.neq
131+(/=) = Native.Basics.neq
132
132
133(<) : comparable -> comparable -> Bool
133(<) : comparable -> comparable -> Bool
134−(<) = Native.lt
134+(<) = Native.Basics.lt
135
135
136(>) : comparable -> comparable -> Bool
136(>) : comparable -> comparable -> Bool
137−(>) = Native.gt
137+(>) = Native.Basics.gt
138
138
139(<=) : comparable -> comparable -> Bool
139(<=) : comparable -> comparable -> Bool
140−(<=) = Native.le
140+(<=) = Native.Basics.le
141
141
142(>=) : comparable -> comparable -> Bool
142(>=) : comparable -> comparable -> Bool
143−(>=) = Native.ge
143+(>=) = Native.Basics.ge
144
144
145-- Compare any two comparable values. Comparable values include `String`, `Char`,
145-- Compare any two comparable values. Comparable values include `String`, `Char`,
146-- `Int`, `Float`, `Time`, or a list or tuple containing comparable values.
146-- `Int`, `Float`, `Time`, or a list or tuple containing comparable values.
147-- These are also the only values that work as `Dict` keys or `Set` members.
147-- These are also the only values that work as `Dict` keys or `Set` members.
148compare : comparable -> comparable -> Order
148compare : comparable -> comparable -> Order
149−compare = Native.compare
149+compare = Native.Basics.compare
150
150
151-- Represents the relative ordering of two things.
151-- Represents the relative ordering of two things.
152-- The relations are less than, equal to, and greater than.
152-- The relations are less than, equal to, and greater than.
@@ -154,19 +154,19 @@ data Order = LT | EQ | GT
154
154
155-- The and operator. True if both inputs are True.
155-- The and operator. True if both inputs are True.
156(&&) : Bool -> Bool -> Bool
156(&&) : Bool -> Bool -> Bool
157−(&&) = Native.and
157+(&&) = Native.Basics.and
158
158
159-- The or operator. True if one or both inputs are True.
159-- The or operator. True if one or both inputs are True.
160(||) : Bool -> Bool -> Bool
160(||) : Bool -> Bool -> Bool
161−(||) = Native.or
161+(||) = Native.Basics.or
162
162
163-- The exclusive-or operator. True if exactly one input is True.
163-- The exclusive-or operator. True if exactly one input is True.
164xor : Bool -> Bool -> Bool
164xor : Bool -> Bool -> Bool
165−xor = Native.xor
165+xor = Native.Basics.xor
166
166
167-- Negate a boolean value: `(not True == False)` and `(not False == True)`
167-- Negate a boolean value: `(not True == False)` and `(not False == True)`
168not : Bool -> Bool
168not : Bool -> Bool
169−not = Native.not
169+not = Native.Basics.not
170
170
171-- Equal to true. Useful as the last case of a multi-way-if.
171-- Equal to true. Useful as the last case of a multi-way-if.
172otherwise : Bool
172otherwise : Bool
@@ -177,35 +177,35 @@ otherwise = True
177
177
178-- Round a number to the nearest integer.
178-- Round a number to the nearest integer.
179round : Float -> Int
179round : Float -> Int
180−round = Native.round
180+round = Native.Basics.round
181
181
182-- Truncate a decimal number, rounding towards zero.
182-- Truncate a decimal number, rounding towards zero.
183truncate : Float -> Int
183truncate : Float -> Int
184−truncate = Native.truncate
184+truncate = Native.Basics.truncate
185
185
186-- Floor function, rounding down.
186-- Floor function, rounding down.
187floor : Float -> Int
187floor : Float -> Int
188−floor = Native.floor
188+floor = Native.Basics.floor
189
189
190-- Ceiling function, rounding up.
190-- Ceiling function, rounding up.
191ceiling : Float -> Int
191ceiling : Float -> Int
192−ceiling = Native.ceiling
192+ceiling = Native.Basics.ceiling
193
193
194-- Convert an integer into a float.
194-- Convert an integer into a float.
195toFloat : Int -> Float
195toFloat : Int -> Float
196−toFloat = Native.toFloat
196+toFloat = Native.Basics.toFloat
197
197
198-- Convert almost any value to its string representation.
198-- Convert almost any value to its string representation.
199show : a -> String
199show : a -> String
200−show = Native.show
200+show = Native.Basics.show
201
201
202-- Read an integer from a string
202-- Read an integer from a string
203-- readInt : String -> Maybe Int
203-- readInt : String -> Maybe Int
204−readInt = Native.readInt
204+--readInt = Native.Basics.readInt
205
205
206-- Read a float from a string.
206-- Read a float from a string.
207-- readFloat : String -> Maybe Float
207-- readFloat : String -> Maybe Float
208−readFloat = Native.readFloat
208+--readFloat = Native.Basics.readFloat
209
209
210-- Function Helpers
210-- Function Helpers
211
211
@@ -244,11 +244,11 @@ id x = x
244
244
245-- Given a 2-tuple, returns the first value.
245-- Given a 2-tuple, returns the first value.
246fst : (a,b) -> a
246fst : (a,b) -> a
247−fst = Native.fst
247+fst = Native.Basics.fst
248
248
249-- Given a 2-tuple, returns the second value.
249-- Given a 2-tuple, returns the second value.
250snd : (a,b) -> b
250snd : (a,b) -> b
251−snd = Native.snd
251+snd = Native.Basics.snd
252
252
253-- Flips the order of the first two arguments to a function.
253-- Flips the order of the first two arguments to a function.
254flip : (a -> b -> c) -> (b -> a -> c)
254flip : (a -> b -> c) -> (b -> a -> c)
@@ -257,9 +257,9 @@ flip f b a = f a b
257-- Change how arguments are passed to a function. This splits paired arguments
257-- Change how arguments are passed to a function. This splits paired arguments
258-- into two separate arguments.
258-- into two separate arguments.
259curry : ((a,b) -> c) -> a -> b -> c
259curry : ((a,b) -> c) -> a -> b -> c
260−curry = Native.curry
260+curry = Native.Basics.curry
261
261
262-- Change how arguments are passed to a function. This combines two arguments
262-- Change how arguments are passed to a function. This combines two arguments
263-- into a sigle pair.
263-- into a sigle pair.
264uncurry : (a -> b -> c) -> (a,b) -> c
264uncurry : (a -> b -> c) -> (a,b) -> c
265−uncurry = Native.uncurry
265+uncurry = Native.Basics.uncurry
libraries/Char.elm+12−12
@@ -1,50 +1,50 @@
1
1
2module Char where
2module Char where
3
3
4−import Native.Char as Native
4+import Native.Char
5
5
6-- True for upper case letters.
6-- True for upper case letters.
7isUpper : Char -> Bool
7isUpper : Char -> Bool
8−isUpper = Native.isUpper
8+isUpper = Native.Char.isUpper
9
9
10-- True for lower case letters.
10-- True for lower case letters.
11isLower : Char -> Bool
11isLower : Char -> Bool
12−isLower = Native.isLower
12+isLower = Native.Char.isLower
13
13
14-- True for ASCII digits (`0..9`).
14-- True for ASCII digits (`0..9`).
15isDigit : Char -> Bool
15isDigit : Char -> Bool
16−isDigit = Native.isDigit
16+isDigit = Native.Char.isDigit
17
17
18-- True for ASCII octal digits (`0..7`).
18-- True for ASCII octal digits (`0..7`).
19isOctDigit : Char -> Bool
19isOctDigit : Char -> Bool
20−isOctDigit = Native.isOctDigit
20+isOctDigit = Native.Char.isOctDigit
21
21
22-- True for ASCII hexadecimal digits (`0..9a..fA..F`).
22-- True for ASCII hexadecimal digits (`0..9a..fA..F`).
23isHexDigit : Char -> Bool
23isHexDigit : Char -> Bool
24−isHexDigit = Native.isHexDigit
24+isHexDigit = Native.Char.isHexDigit
25
25
26-- Convert to upper case.
26-- Convert to upper case.
27toUpper : Char -> Char
27toUpper : Char -> Char
28−toUpper = Native.toUpper
28+toUpper = Native.Char.toUpper
29
29
30-- Convert to lower case.
30-- Convert to lower case.
31toLower : Char -> Char
31toLower : Char -> Char
32−toLower = Native.toLower
32+toLower = Native.Char.toLower
33
33
34-- Convert to upper case, according to any locale-specific case mappings.
34-- Convert to upper case, according to any locale-specific case mappings.
35toLocaleUpper : Char -> Char
35toLocaleUpper : Char -> Char
36−toLocaleUpper = Native.toLocaleUpper
36+toLocaleUpper = Native.Char.toLocaleUpper
37
37
38-- Convert to lower case, according to any locale-specific case mappings.
38-- Convert to lower case, according to any locale-specific case mappings.
39toLocaleLower : Char -> Char
39toLocaleLower : Char -> Char
40−toLocaleLower = Native.toLocaleLower
40+toLocaleLower = Native.Char.toLocaleLower
41
41
42type KeyCode = Int
42type KeyCode = Int
43
43
44-- Convert to unicode.
44-- Convert to unicode.
45toCode : Char -> KeyCode
45toCode : Char -> KeyCode
46−toCode = Native.toCode
46+toCode = Native.Char.toCode
47
47
48-- Convert from unicode.
48-- Convert from unicode.
49fromCode : KeyCode -> Char
49fromCode : KeyCode -> Char
50−fromCode = Native.fromCode
50+fromCode = Native.Char.fromCode
libraries/Color.elm+4−4
@@ -1,7 +1,7 @@
1
1
2module Color where
2module Color where
3
3
4−import Native.Color as Native
4+import Native.Color
5
5
6data Color = Color Int Int Int Float
6data Color = Color Int Int Int Float
7
7
@@ -58,19 +58,19 @@ forestGreen = Color 34 139 34 1
58-- Produce a &ldquo;complementary color&rdquo;.
58-- Produce a &ldquo;complementary color&rdquo;.
59-- The two colors will accent each other.
59-- The two colors will accent each other.
60complement : Color -> Color
60complement : Color -> Color
61−complement = Native.complement
61+complement = Native.Color.complement
62
62
63-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV)
63-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV)
64-- with an alpha component for transparency.
64-- with an alpha component for transparency.
65hsva : Float -> Float -> Float -> Float -> Color
65hsva : Float -> Float -> Float -> Float -> Color
66−hsva = Native.hsva
66+hsva = Native.Color.hsva
67
67
68-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV).
68-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV).
69-- This is very convenient for creating colors that cycle and shift.
69-- This is very convenient for creating colors that cycle and shift.
70--
70--
71-- hsv (degrees 240) 1 1 == blue
71-- hsv (degrees 240) 1 1 == blue
72hsv : Float -> Float -> Float -> Color
72hsv : Float -> Float -> Float -> Color
73−hsv = Native.hsv
73+hsv = Native.Color.hsv
74
74
75data Gradient
75data Gradient
76 = Linear (Float,Float) (Float,Float) [(Float,Color)]
76 = Linear (Float,Float) (Float,Float) [(Float,Color)]
libraries/Date.elm+10−10
@@ -5,7 +5,7 @@
5module Date where
5module Date where
6
6
7import Basics (String)
7import Basics (String)
8−import Native.Date as Native
8+import Native.Date
9import Time (Time)
9import Time (Time)
10import Maybe (Maybe)
10import Maybe (Maybe)
11
11
@@ -21,45 +21,45 @@ data Month = Jan | Feb | Mar | Apr
21
21
22-- Attempt to read a date from a string.
22-- Attempt to read a date from a string.
23read : String -> Maybe Date
23read : String -> Maybe Date
24−read = Native.read
24+read = Native.Date.read
25
25
26-- Convert a date into a time since midnight (UTC) of 1 January 1990 (i.e.
26-- Convert a date into a time since midnight (UTC) of 1 January 1990 (i.e.
27-- [UNIX time](http://en.wikipedia.org/wiki/Unix_time)). Given the date 23 June
27-- [UNIX time](http://en.wikipedia.org/wiki/Unix_time)). Given the date 23 June
28-- 1990 at 11:45AM this returns the corresponding time.
28-- 1990 at 11:45AM this returns the corresponding time.
29toTime : Date -> Time
29toTime : Date -> Time
30−toTime = Native.toTime
30+toTime = Native.Date.toTime
31
31
32-- Extract the year of a given date. Given the date 23 June 1990 at 11:45AM
32-- Extract the year of a given date. Given the date 23 June 1990 at 11:45AM
33-- this returns the integer `1990`.
33-- this returns the integer `1990`.
34year : Date -> Int
34year : Date -> Int
35−year = Native.year
35+year = Native.Date.year
36
36
37-- Extract the month of a given date. Given the date 23 June 1990 at 11:45AM
37-- Extract the month of a given date. Given the date 23 June 1990 at 11:45AM
38-- this returns the Month `Jun` as defined below.
38-- this returns the Month `Jun` as defined below.
39month : Date -> Month
39month : Date -> Month
40−month = Native.month
40+month = Native.Date.month
41
41
42-- Extract the day of a given date. Given the date 23 June 1990 at 11:45AM
42-- Extract the day of a given date. Given the date 23 June 1990 at 11:45AM
43-- this returns the integer `23`.
43-- this returns the integer `23`.
44day : Date -> Int
44day : Date -> Int
45−day = Native.day
45+day = Native.Date.day
46
46
47-- Extract the day of the week for a given date. Given the date 23 June
47-- Extract the day of the week for a given date. Given the date 23 June
48-- 1990 at 11:45AM this returns the Day `Thu` as defined below.
48-- 1990 at 11:45AM this returns the Day `Thu` as defined below.
49dayOfWeek : Date -> Day
49dayOfWeek : Date -> Day
50−dayOfWeek = Native.dayOfWeek
50+dayOfWeek = Native.Date.dayOfWeek
51
51
52-- Extract the hour of a given date. Given the date 23 June 1990 at 11:45AM
52-- Extract the hour of a given date. Given the date 23 June 1990 at 11:45AM
53-- this returns the integer `11`.
53-- this returns the integer `11`.
54hour : Date -> Int
54hour : Date -> Int
55−hour = Native.hour
55+hour = Native.Date.hour
56
56
57-- Extract the minute of a given date. Given the date 23 June 1990 at 11:45AM
57-- Extract the minute of a given date. Given the date 23 June 1990 at 11:45AM
58-- this returns the integer `45`.
58-- this returns the integer `45`.
59minute : Date -> Int
59minute : Date -> Int
60−minute = Native.minute
60+minute = Native.Date.minute
61
61
62-- Extract the second of a given date. Given the date 23 June 1990 at 11:45AM
62-- Extract the second of a given date. Given the date 23 June 1990 at 11:45AM
63-- this returns the integer `0`.
63-- this returns the integer `0`.
64second : Date -> Int
64second : Date -> Int
65−second = Native.second
65+second = Native.Date.second
libraries/Dict.elm+5−5
@@ -12,7 +12,7 @@ import open Basics
12import open Maybe
12import open Maybe
13import Native.Error
13import Native.Error
14import List as List
14import List as List
15−import Native.Utils (compare)
15+import Native.Utils
16
16
17data NColor = Red | Black
17data NColor = Red | Black
18
18
@@ -122,7 +122,7 @@ lookup k t =
122 case t of
122 case t of
123 RBEmpty -> Nothing
123 RBEmpty -> Nothing
124 RBNode _ k' v l r ->
124 RBNode _ k' v l r ->
125− case compare k k' of
125+ case Native.Utils.compare k k' of
126 LT -> lookup k l
126 LT -> lookup k l
127 EQ -> Just v
127 EQ -> Just v
128 GT -> lookup k r
128 GT -> lookup k r
@@ -134,7 +134,7 @@ findWithDefault base k t =
134 case t of
134 case t of
135 RBEmpty -> base
135 RBEmpty -> base
136 RBNode _ k' v l r ->
136 RBNode _ k' v l r ->
137− case compare k k' of
137+ case Native.Utils.compare k k' of
138 LT -> findWithDefault base k l
138 LT -> findWithDefault base k l
139 EQ -> v
139 EQ -> v
140 GT -> findWithDefault base k r
140 GT -> findWithDefault base k r
@@ -145,7 +145,7 @@ find k t =
145 case t of
145 case t of
146 { RBEmpty -> Native.Error.raise "Key was not found in dictionary!"
146 { RBEmpty -> Native.Error.raise "Key was not found in dictionary!"
147 ; RBNode _ k' v l r ->
147 ; RBNode _ k' v l r ->
148− case compare k k' of
148+ case Native.Utils.compare k k' of
149 { LT -> find k l
149 { LT -> find k l
150 ; EQ -> v
150 ; EQ -> v
151 ; GT -> find k r }
151 ; GT -> find k r }
@@ -216,7 +216,7 @@ insert k v t = -- Invariant: t is a valid left-leaning rb tree
216 case t of
216 case t of
217 RBEmpty -> RBNode Red k v RBEmpty RBEmpty
217 RBEmpty -> RBNode Red k v RBEmpty RBEmpty
218 RBNode c k' v' l r ->
218 RBNode c k' v' l r ->
219− let h = case compare k k' of
219+ let h = case Native.Utils.compare k k' of
220 LT -> RBNode c k' v' (ins l) r
220 LT -> RBNode c k' v' (ins l) r
221 EQ -> RBNode c k' v l r -- replace
221 EQ -> RBNode c k' v l r -- replace
222 GT -> RBNode c k' v' l (ins r)
222 GT -> RBNode c k' v' l (ins r)
libraries/Graphics/Collage.elm+2−2
@@ -5,7 +5,7 @@ import open Basics
5import List
5import List
6import Either (Either, Left, Right)
6import Either (Either, Left, Right)
7import Matrix2D (Matrix2D, identity)
7import Matrix2D (Matrix2D, identity)
8−import Native.Graphics.Collage as Native
8+import Native.Graphics.Collage
9import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
9import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
10import Color (Color, black, Gradient)
10import Color (Color, black, Gradient)
11import Maybe (Maybe)
11import Maybe (Maybe)
@@ -158,7 +158,7 @@ opacity a f = { f | alpha <- a }
158-- A collage is a collection of 2D forms. There are no strict positioning
158-- A collage is a collection of 2D forms. There are no strict positioning
159-- relationships between forms, so you are free to do all kinds of 2D graphics.
159-- relationships between forms, so you are free to do all kinds of 2D graphics.
160collage : Int -> Int -> [Form] -> Element
160collage : Int -> Int -> [Form] -> Element
161−collage = Native.collage
161+collage = Native.Graphics.Collage.collage
162
162
163
163
164type Path = [(Float,Float)]
164type Path = [(Float,Float)]
libraries/Graphics/Element.elm+4−15
@@ -1,19 +1,8 @@
1
1
2−module Graphics.Element (widthOf, heightOf, sizeOf,
2+module Graphics.Element where
3− width, height, size, opacity, color, tag, link,
4− image, fittedImage, croppedImage, tiledImage,
5− flow, up, down, left, right, inward, outward,
6− above, below, beside, layers,
7− container, absolute, relative,
8− middle, topLeft, topRight, bottomLeft, bottomRight,
9− midLeft, midRight, midTop, midBottom, middleAt,
10− topLeftAt, topRightAt, bottomLeftAt, bottomRightAt,
11− midLeftAt, midRightAt, midTopAt, midBottomAt,
12− spacer, newElement, Three, Pos, ElementPrim, Properties
13− ) where
14
3
15import open Basics
4import open Basics
16−import Native.Utils as Native
5+import Native.Utils
17import open JavaScript
6import open JavaScript
18import List as List
7import List as List
19import open Color
8import open Color
@@ -49,7 +38,7 @@ width : Int -> Element -> Element
49width nw e = let p = e.props
38width nw e = let p = e.props
50 props = case e.element of
39 props = case e.element of
51 Image _ w h _ -> {p| height <- h `div` w * nw }
40 Image _ w h _ -> {p| height <- h `div` w * nw }
52− RawHtml html -> {p| height <- let (w,h) = Native.htmlHeight nw html in h}
41+ RawHtml html -> {p| height <- let (w,h) = Native.Utils.htmlHeight nw html in h}
53 _ -> p
42 _ -> p
54 in { element=e.element, props={ props | width <- nw } }
43 in { element=e.element, props={ props | width <- nw } }
55
44
@@ -91,7 +80,7 @@ link href e = let p = e.props in
91
80
92emptyStr = fromString ""
81emptyStr = fromString ""
93newElement w h e =
82newElement w h e =
94− { props = Properties (Native.guid ()) w h 1 Nothing emptyStr emptyStr (), element = e }
83+ { props = Properties (Native.Utils.guid ()) w h 1 Nothing emptyStr emptyStr (), element = e }
95
84
96data ElementPrim
85data ElementPrim
97 = Image ImageStyle Int Int JSString
86 = Image ImageStyle Int Int JSString
libraries/Graphics/Input.elm+16−16
@@ -3,7 +3,7 @@ module Graphics.Input where
3
3
4import Basics (String)
4import Basics (String)
5import Signal (Signal,lift,dropRepeats)
5import Signal (Signal,lift,dropRepeats)
6−import Native.Graphics.Input as Native
6+import Native.Graphics.Input
7import List
7import List
8import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
8import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
9import Color (Color)
9import Color (Color)
@@ -22,13 +22,13 @@ id x = x
22-- The `a` value is sent to `events` whenever the button is pressed.
22-- The `a` value is sent to `events` whenever the button is pressed.
23buttons : a -> { events : Signal a,
23buttons : a -> { events : Signal a,
24 button : a -> String -> Element }
24 button : a -> String -> Element }
25−buttons = Native.buttons
25+buttons = Native.Graphics.Input.buttons
26
26
27-- Create a button with a given label. The result is an `Element` and
27-- Create a button with a given label. The result is an `Element` and
28-- a signal of units. This signal triggers whenever the button is pressed.
28-- a signal of units. This signal triggers whenever the button is pressed.
29button : String -> (Element, Signal ())
29button : String -> (Element, Signal ())
30button txt =
30button txt =
31− let pool = Native.buttons ()
31+ let pool = buttons ()
32 in (pool.button () txt, pool.events)
32 in (pool.button () txt, pool.events)
33
33
34-- Create a group of custom buttons.
34-- Create a group of custom buttons.
@@ -42,14 +42,14 @@ button txt =
42-- The `a` value is sent to `events` whenever the button is pressed.
42-- The `a` value is sent to `events` whenever the button is pressed.
43customButtons : a -> { events : Signal a,
43customButtons : a -> { events : Signal a,
44 customButton : a -> Element -> Element -> Element -> Element }
44 customButton : a -> Element -> Element -> Element -> Element }
45−customButtons = Native.customButtons
45+customButtons = Native.Graphics.Input.customButtons
46
46
47-- Create a button with custom states for up, hovering, and down
47-- Create a button with custom states for up, hovering, and down
48-- (given in that order). The result is an `Element` and
48-- (given in that order). The result is an `Element` and
49-- a signal of units. This signal triggers whenever the button is pressed.
49-- a signal of units. This signal triggers whenever the button is pressed.
50customButton : Element -> Element -> Element -> (Element, Signal ())
50customButton : Element -> Element -> Element -> (Element, Signal ())
51customButton up hover down =
51customButton up hover down =
52− let pool = Native.customButtons ()
52+ let pool = customButtons ()
53 in (pool.customButton () up hover down, pool.events)
53 in (pool.customButton () up hover down, pool.events)
54
54
55-- Create a group of checkboxes.
55-- Create a group of checkboxes.
@@ -64,7 +64,7 @@ customButton up hover down =
64-- lets you add an ID to distinguish between checkboxes.
64-- lets you add an ID to distinguish between checkboxes.
65checkboxes : a -> { events : Signal a,
65checkboxes : a -> { events : Signal a,
66 checkbox : (Bool -> a) -> Bool -> Element }
66 checkbox : (Bool -> a) -> Bool -> Element }
67−checkboxes = Native.checkboxes
67+checkboxes = Native.Graphics.Input.checkboxes
68
68
69-- Create a checkbox with a given start state. Unlike `button`, this result
69-- Create a checkbox with a given start state. Unlike `button`, this result
70-- is a *signal* of elements. That is because a checkbox has state that
70-- is a *signal* of elements. That is because a checkbox has state that
@@ -72,16 +72,16 @@ checkboxes = Native.checkboxes
72-- The boolean signal represents the current state of the checkbox.
72-- The boolean signal represents the current state of the checkbox.
73checkbox : Bool -> (Signal Element, Signal Bool)
73checkbox : Bool -> (Signal Element, Signal Bool)
74checkbox b =
74checkbox b =
75− let cbs = Native.checkboxes b
75+ let cbs = checkboxes b
76− in (lift (cbs.box id) cbs.events, cbs.events)
76+ in (lift (cbs.checkbox id) cbs.events, cbs.events)
77
77
78hoverables : a -> { events : Signal a,
78hoverables : a -> { events : Signal a,
79 hoverable : (Bool -> a) -> Element -> Element }
79 hoverable : (Bool -> a) -> Element -> Element }
80−hoverables = Native.hoverables
80+hoverables = Native.Graphics.Input.hoverables
81
81
82hoverable : Element -> (Element, Signal Bool)
82hoverable : Element -> (Element, Signal Bool)
83hoverable elem =
83hoverable elem =
84− let pool = Native.hoverables False
84+ let pool = hoverables False
85 in (pool.hoverable id elem, pool.events)
85 in (pool.hoverable id elem, pool.events)
86
86
87-- Represents the current state of a text field. The `string` represents the
87-- Represents the current state of a text field. The `string` represents the
@@ -107,7 +107,7 @@ type FieldState = { string:String, selectionStart:Int, selectionEnd:Int }
107-- lets you add an ID to distinguish between input fields.
107-- lets you add an ID to distinguish between input fields.
108fields : a -> { events : Signal a,
108fields : a -> { events : Signal a,
109 field : (FieldState -> a) -> String -> FieldState -> Element }
109 field : (FieldState -> a) -> String -> FieldState -> Element }
110−fields = Native.fields
110+fields = Native.Graphics.Input.fields
111
111
112-- The empty field state:
112-- The empty field state:
113--
113--
@@ -120,7 +120,7 @@ emptyFieldState = { string="", selectionStart=0, selectionEnd=0 }
120-- content of the field.
120-- content of the field.
121field : String -> (Signal Element, Signal String)
121field : String -> (Signal Element, Signal String)
122field placeHolder =
122field placeHolder =
123− let tfs = Native.fields emptyFieldState
123+ let tfs = fields emptyFieldState
124 changes = dropRepeats tfs.events
124 changes = dropRepeats tfs.events
125 in (lift (tfs.field id placeHolder) changes,
125 in (lift (tfs.field id placeHolder) changes,
126 dropRepeats (lift .string changes))
126 dropRepeats (lift .string changes))
@@ -128,7 +128,7 @@ field placeHolder =
128-- Same as `field` but the UI element blocks out each characters.
128-- Same as `field` but the UI element blocks out each characters.
129password : String -> (Signal Element, Signal String)
129password : String -> (Signal Element, Signal String)
130password placeHolder =
130password placeHolder =
131− let tfs = Native.passwords emptyFieldState
131+ let tfs = Native.Graphics.Input.passwords emptyFieldState
132 changes = dropRepeats tfs.events
132 changes = dropRepeats tfs.events
133 in (lift (tfs.field id placeHolder) changes,
133 in (lift (tfs.field id placeHolder) changes,
134 dropRepeats (lift .string changes))
134 dropRepeats (lift .string changes))
@@ -138,7 +138,7 @@ password placeHolder =
138-- get a custom keyboard with an `@` and `.com` button.
138-- get a custom keyboard with an `@` and `.com` button.
139email : String -> (Signal Element, Signal String)
139email : String -> (Signal Element, Signal String)
140email placeHolder =
140email placeHolder =
141− let tfs = Native.emails emptyFieldState
141+ let tfs = Native.Graphics.Input.emails emptyFieldState
142 changes = dropRepeats tfs.events
142 changes = dropRepeats tfs.events
143 in (lift (tfs.field id placeHolder) changes,
143 in (lift (tfs.field id placeHolder) changes,
144 dropRepeats (lift .string changes))
144 dropRepeats (lift .string changes))
@@ -148,10 +148,10 @@ email placeHolder =
148-- value. This lets you avoid manually mapping the string onto
148-- value. This lets you avoid manually mapping the string onto
149-- functions and values.
149-- functions and values.
150dropDown : [(String,a)] -> (Signal Element, Signal a)
150dropDown : [(String,a)] -> (Signal Element, Signal a)
151−dropDown = Native.dropDown
151+dropDown = Native.Graphics.Input.dropDown
152
152
153-- Create a drop-down menu for selecting strings. The resulting
153-- Create a drop-down menu for selecting strings. The resulting
154-- signal of strings represents the string that is currently selected.
154-- signal of strings represents the string that is currently selected.
155stringDropDown : [String] -> (Signal Element, Signal String)
155stringDropDown : [String] -> (Signal Element, Signal String)
156stringDropDown strs =
156stringDropDown strs =
157− Native.dropDown (List.map (\s -> (s,s)) strs)
157+ dropDown (List.map (\s -> (s,s)) strs)
libraries/Http.elm+2−2
@@ -6,7 +6,7 @@ module Http where
6
6
7import open Basics
7import open Basics
8import open Signal
8import open Signal
9−import Native.Http as Native
9+import Native.Http
10
10
11-- The datatype for responses. Success contains only the returned message.
11-- The datatype for responses. Success contains only the returned message.
12-- Failures contain both an error code and an error message.
12-- Failures contain both an error code and an error message.
@@ -36,7 +36,7 @@ post url body = Request "POST" url body []
36-- Performs an HTTP request with the given requests. Produces a signal
36-- Performs an HTTP request with the given requests. Produces a signal
37-- that carries the responses.
37-- that carries the responses.
38send : Signal (Request a) -> Signal (Response String)
38send : Signal (Request a) -> Signal (Response String)
39−send = Native.send
39+send = Native.Http.send
40
40
41-- Performs an HTTP GET request with the given urls. Produces a signal
41-- Performs an HTTP GET request with the given urls. Produces a signal
42-- that carries the responses.
42-- that carries the responses.
libraries/JavaScript.elm+13−13
@@ -1,7 +1,7 @@
1
1
2module JavaScript where
2module JavaScript where
3
3
4−import Native.JavaScript as Native
4+import Native.JavaScript
5import open Basics
5import open Basics
6
6
7data JSNumber = JSNumber
7data JSNumber = JSNumber
@@ -13,44 +13,44 @@ data JSObject = JSObject
13
13
14-- Requires that the input array be uniform (all members have the same type)
14-- Requires that the input array be uniform (all members have the same type)
15toList : JSArray a -> [a]
15toList : JSArray a -> [a]
16−toList = Native.toList
16+toList = Native.JavaScript.toList
17
17
18toInt : JSNumber -> Int
18toInt : JSNumber -> Int
19−toInt = Native.toInt
19+toInt = Native.JavaScript.toInt
20
20
21toFloat : JSNumber -> Float
21toFloat : JSNumber -> Float
22−toFloat = Native.toFloat
22+toFloat = Native.JavaScript.toFloat
23
23
24toBool : JSBool -> Bool
24toBool : JSBool -> Bool
25−toBool = Native.toBool
25+toBool = Native.JavaScript.toBool
26
26
27toString : JSString -> String
27toString : JSString -> String
28−toString = Native.toString
28+toString = Native.JavaScript.toString
29
29
30
30
31-- Produces a uniform JavaScript array with all members of the same type.
31-- Produces a uniform JavaScript array with all members of the same type.
32fromList : [a] -> JSArray a
32fromList : [a] -> JSArray a
33−fromList = Native.fromList
33+fromList = Native.JavaScript.fromList
34
34
35fromInt : Int -> JSNumber
35fromInt : Int -> JSNumber
36−fromInt = Native.fromInt
36+fromInt = Native.JavaScript.fromInt
37
37
38fromFloat : Float -> JSNumber
38fromFloat : Float -> JSNumber
39−fromFloat = Native.fromFloat
39+fromFloat = Native.JavaScript.fromFloat
40
40
41fromBool : Bool -> JSBool
41fromBool : Bool -> JSBool
42−fromBool = Native.fromBool
42+fromBool = Native.JavaScript.fromBool
43
43
44fromString : String -> JSString
44fromString : String -> JSString
45−fromString = Native.fromString
45+fromString = Native.JavaScript.fromString
46
46
47{--
47{--
48-- Turn an `Element` into a plain old DOM node.
48-- Turn an `Element` into a plain old DOM node.
49fromElement : Element -> JSDomNode
49fromElement : Element -> JSDomNode
50−fromElement = Native.fromElement
50+fromElement = Native.JavaScript.fromElement
51
51
52-- Turn a DOM node into an `Element`. You can resize the node
52-- Turn a DOM node into an `Element`. You can resize the node
53-- using the normal `width` and `height` functions.
53-- using the normal `width` and `height` functions.
54toElement : Int -> Int -> JSDomNode -> Element
54toElement : Int -> Int -> JSDomNode -> Element
55−toElement = Native.toElement
55+toElement = Native.JavaScript.toElement
56--}
56--}
libraries/JavaScript/Experimental.elm+3−3
@@ -2,7 +2,7 @@
2module JavaScript.Experimental where
2module JavaScript.Experimental where
3
3
4import JavaScript (JSObject)
4import JavaScript (JSObject)
5−import Native.JavaScript as Native
5+import Native.JavaScript
6
6
7-- Turn arbitrary JavaScript objects into Elm records.
7-- Turn arbitrary JavaScript objects into Elm records.
8-- Arrays are converted into lists, nested objects are allowed.
8-- Arrays are converted into lists, nested objects are allowed.
@@ -16,7 +16,7 @@ import Native.JavaScript as Native
16-- { answer:null }
16-- { answer:null }
17-- { info:[true,42,'what'] }
17-- { info:[true,42,'what'] }
18toRecord : JSObject -> a
18toRecord : JSObject -> a
19−toRecord = Native.toRecord
19+toRecord = Native.JavaScript.toRecord
20
20
21-- Turn arbitrary Elm records into JavaScript objects.
21-- Turn arbitrary Elm records into JavaScript objects.
22-- Lists become arrays, nested records are allowed. No ADTs.
22-- Lists become arrays, nested records are allowed. No ADTs.
@@ -29,4 +29,4 @@ toRecord = Native.toRecord
29-- { answer = Nothing }
29-- { answer = Nothing }
30-- { result = Left "An error occurred" }
30-- { result = Left "An error occurred" }
31fromRecord : a -> JSObject
31fromRecord : a -> JSObject
32−fromRecord = Native.fromRecord
32+fromRecord = Native.JavaScript.fromRecord
libraries/Json.elm+7−7
@@ -7,7 +7,7 @@ import open Basics
7import Dict
7import Dict
8import Maybe (Maybe)
8import Maybe (Maybe)
9import JavaScript as JS
9import JavaScript as JS
10−import Native.Json as Native
10+import Native.Json
11import JavaScript (JSObject, JSString)
11import JavaScript (JSObject, JSString)
12
12
13-- This datatype can represent all valid values that can be held in a JSON
13-- This datatype can represent all valid values that can be held in a JSON
@@ -28,27 +28,27 @@ data JsonValue
28-- The first argument is a separator token (e.g. \" \", \"\\n\", etc.) that will
28-- The first argument is a separator token (e.g. \" \", \"\\n\", etc.) that will
29-- be used for indentation in the prettified string version of the JSON.
29-- be used for indentation in the prettified string version of the JSON.
30toString : String -> JsonValue -> String
30toString : String -> JsonValue -> String
31−toString sep v = JS.toString (Native.toJSString sep v)
31+toString sep v = JS.toString (Native.Json.toJSString sep v)
32
32
33-- Convert a proper JSON object into a JavaScript string.
33-- Convert a proper JSON object into a JavaScript string.
34-- Note that the type JSString seen here is not the same as the type constructor
34-- Note that the type JSString seen here is not the same as the type constructor
35-- JsonString used elsewhere in this module.
35-- JsonString used elsewhere in this module.
36toJSString : String -> JsonValue -> JSString
36toJSString : String -> JsonValue -> JSString
37−toJSString = Native.toJSString
37+toJSString = Native.Json.toJSString
38
38
39-- Parse a string representation of a proper JSON object into
39-- Parse a string representation of a proper JSON object into
40-- its Elm representation.
40-- its Elm representation.
41fromString : String -> Maybe JsonValue
41fromString : String -> Maybe JsonValue
42−fromString s = Native.fromJSString (JS.fromString s)
42+fromString s = Native.Json.fromJSString (JS.fromString s)
43
43
44-- Parse a JavaScript string representation of a proper JSON object into
44-- Parse a JavaScript string representation of a proper JSON object into
45-- its Elm representation.
45-- its Elm representation.
46fromJSString : JSString -> Maybe JsonValue
46fromJSString : JSString -> Maybe JsonValue
47−fromJSString = Native.fromJSString
47+fromJSString = Native.Json.fromJSString
48
48
49-- Convert a JS object into a `JsonValue`.
49-- Convert a JS object into a `JsonValue`.
50fromJSObject : JSObject -> JsonValue
50fromJSObject : JSObject -> JsonValue
51−fromJSObject = Native.fromJSObject
51+fromJSObject = Native.Json.fromJSObject
52
52
53-- Convert a `JsonValue` into a `JSObject`. Paired with the
53-- Convert a `JsonValue` into a `JSObject`. Paired with the
54-- [`JavaScript.Experimental` library](/docs/JavaScript/Experimental.elm),
54-- [`JavaScript.Experimental` library](/docs/JavaScript/Experimental.elm),
@@ -61,7 +61,7 @@ fromJSObject = Native.fromJSObject
61-- Just jsonValue -> Just (JS.toRecord (toJSObject jsonValue))
61-- Just jsonValue -> Just (JS.toRecord (toJSObject jsonValue))
62-- Nothing -> Nothing
62-- Nothing -> Nothing
63toJSObject : JsonValue -> JSObject
63toJSObject : JsonValue -> JSObject
64−toJSObject = Native.toJSObject
64+toJSObject = Native.Json.toJSObject
65
65
66 {-- Extract Elm values from Json values
66 {-- Extract Elm values from Json values
67
67
libraries/Keyboard.elm+16−16
@@ -1,13 +1,19 @@
1module Keyboard where
1module Keyboard where
2
2
3import Signal (Signal)
3import Signal (Signal)
4−import Native.Keyboard as Native
4+import Native.Keyboard
5
5
6-- Type alias to make it clearer what integers are supposed to represent
6-- Type alias to make it clearer what integers are supposed to represent
7-- in this library. Use [`Char.toCode`](docs/Char.elm#toCode) and
7-- in this library. Use [`Char.toCode`](docs/Char.elm#toCode) and
8-- [`Char.fromCode`](/docs/Char.elm#fromCode) to convert key codes to characters.
8-- [`Char.fromCode`](/docs/Char.elm#fromCode) to convert key codes to characters.
9type KeyCode = Int
9type KeyCode = Int
10
10
11+-- Custom key directions so that you can support different locales.
12+-- The plan is to have a locale independent version of this function
13+-- that uses the physical location of keys, but I don't know how to do it.
14+directions : KeyCode -> KeyCode -> KeyCode -> KeyCode -> Signal { x:Int, y:Int }
15+directions = Native.Keyboard.directions
16+
11-- A signal of records indicating which arrow keys are pressed.
17-- A signal of records indicating which arrow keys are pressed.
12--
18--
13-- `{ x = 0, y = 0 }` when pressing no arrows.<br>
19-- `{ x = 0, y = 0 }` when pressing no arrows.<br>
@@ -15,43 +21,37 @@ type KeyCode = Int
15-- `{ x = 1, y = 1 }` when pressing the up and right arrows.<br>
21-- `{ x = 1, y = 1 }` when pressing the up and right arrows.<br>
16-- `{ x = 0, y =-1 }` when pressing the down, left, and right arrows.
22-- `{ x = 0, y =-1 }` when pressing the down, left, and right arrows.
17arrows : Signal { x:Int, y:Int }
23arrows : Signal { x:Int, y:Int }
18−arrows = Native.directions 38 40 37 39
24+arrows = directions 38 40 37 39
19
25
20-- Just like the arrows signal, but this uses keys w, a, s, and d,
26-- Just like the arrows signal, but this uses keys w, a, s, and d,
21-- which are common controls for many computer games.
27-- which are common controls for many computer games.
22wasd : Signal { x:Int, y:Int }
28wasd : Signal { x:Int, y:Int }
23−wasd = Native.directions 87 83 65 68
29+wasd = directions 87 83 65 68
24−
25−-- Custom key directions so that you can support different locales.
26−-- The plan is to have a locale independent version of this function
27−-- that uses the physical location of keys, but I don't know how to do it.
28−directions : KeyCode -> KeyCode -> KeyCode -> KeyCode -> Signal { x:Int, y:Int }
29−directions = Native.directions
30
30
31-- Whether an arbitrary key is pressed.
31-- Whether an arbitrary key is pressed.
32isDown : KeyCode -> Signal Bool
32isDown : KeyCode -> Signal Bool
33−isDown = Native.isDown
33+isDown = Native.Keyboard.isDown
34
34
35-- Whether the shift key is pressed.
35-- Whether the shift key is pressed.
36shift : Signal Bool
36shift : Signal Bool
37−shift = Native.isDown 16
37+shift = isDown 16
38
38
39-- Whether the control key is pressed.
39-- Whether the control key is pressed.
40ctrl : Signal Bool
40ctrl : Signal Bool
41−ctrl = Native.isDown 17
41+ctrl = isDown 17
42
42
43-- Whether the space key is pressed.
43-- Whether the space key is pressed.
44space : Signal Bool
44space : Signal Bool
45−space = Native.isDown 32
45+space = isDown 32
46
46
47-- Whether the enter key is pressed.
47-- Whether the enter key is pressed.
48enter : Signal Bool
48enter : Signal Bool
49−enter = Native.isDown 13
49+enter = isDown 13
50
50
51-- List of keys that are currently down.
51-- List of keys that are currently down.
52keysDown : Signal [KeyCode]
52keysDown : Signal [KeyCode]
53−keysDown = Native.keysDown
53+keysDown = Native.Keyboard.keysDown
54
54
55-- The latest key that has been pressed.
55-- The latest key that has been pressed.
56lastPressed : Signal KeyCode
56lastPressed : Signal KeyCode
57−lastPressed = Native.lastPressed
57+lastPressed = Native.Keyboard.lastPressed
libraries/List.elm+27−27
@@ -2,33 +2,33 @@
2module List where
2module List where
3
3
4import open Basics
4import open Basics
5−import Native.List as Native
5+import Native.List
6
6
7-- Add an element to the front of a list `(1 :: [2,3] == [1,2,3])`
7-- Add an element to the front of a list `(1 :: [2,3] == [1,2,3])`
8(::) : a -> [a] -> [a]
8(::) : a -> [a] -> [a]
9−(::) = Native.cons
9+(::) = Native.List.cons
10
10
11-- Puts two appendable things together:
11-- Puts two appendable things together:
12--
12--
13-- [1,1] ++ [2,3] == [1,1,2,3]
13-- [1,1] ++ [2,3] == [1,1,2,3]
14-- "abc" ++ "123" == "abc123"
14-- "abc" ++ "123" == "abc123"
15(++) : appendable -> appendable -> appendable
15(++) : appendable -> appendable -> appendable
16−(++) = Native.append
16+(++) = Native.List.append
17
17
18-- Extract the first element of a list. List must be non-empty.
18-- Extract the first element of a list. List must be non-empty.
19-- `(head [1,2,3] == 1)`
19-- `(head [1,2,3] == 1)`
20head : [a] -> a
20head : [a] -> a
21−head = Native.head
21+head = Native.List.head
22
22
23-- Extract the elements after the head of the list. List must be non-empty.
23-- Extract the elements after the head of the list. List must be non-empty.
24-- `(tail [1,2,3] == [2,3])`
24-- `(tail [1,2,3] == [2,3])`
25tail : [a] -> [a]
25tail : [a] -> [a]
26−tail = Native.tail
26+tail = Native.List.tail
27
27
28-- Extract the last element of a list. List must be non-empty.
28-- Extract the last element of a list. List must be non-empty.
29-- `(last [1,2,3] == 3)`
29-- `(last [1,2,3] == 3)`
30last : [a] -> a
30last : [a] -> a
31−last = Native.last
31+last = Native.List.last
32
32
33-- Check if a list is empty `(isEmpty [] == True)`
33-- Check if a list is empty `(isEmpty [] == True)`
34isEmpty : [a] -> Bool
34isEmpty : [a] -> Bool
@@ -39,69 +39,69 @@ isEmpty xs =
39
39
40-- Apply a function to every element of a list: `(map sqrt [1,4,9] == [1,2,3])`
40-- Apply a function to every element of a list: `(map sqrt [1,4,9] == [1,2,3])`
41map : (a -> b) -> [a] -> [b]
41map : (a -> b) -> [a] -> [b]
42−map = Native.map
42+map = Native.List.map
43
43
44-- Reduce a list from the left: `(foldl (::) [] "gateman" == "nametag")`
44-- Reduce a list from the left: `(foldl (::) [] "gateman" == "nametag")`
45foldl : (a -> b -> b) -> b -> [a] -> b
45foldl : (a -> b -> b) -> b -> [a] -> b
46−foldl = Native.foldl
46+foldl = Native.List.foldl
47
47
48-- Reduce a list from the right: `(foldr (+) 0 [1,2,3] == 6)`
48-- Reduce a list from the right: `(foldr (+) 0 [1,2,3] == 6)`
49foldr : (a -> b -> b) -> b -> [a] -> b
49foldr : (a -> b -> b) -> b -> [a] -> b
50−foldr = Native.foldr
50+foldr = Native.List.foldr
51
51
52-- Reduce a list from the left without a base case. List must be non-empty.
52-- Reduce a list from the left without a base case. List must be non-empty.
53foldl1 : (a -> a -> a) -> [a] -> a
53foldl1 : (a -> a -> a) -> [a] -> a
54−foldl1 = Native.foldl1
54+foldl1 = Native.List.foldl1
55
55
56-- Reduce a list from the right without a base case. List must be non-empty.
56-- Reduce a list from the right without a base case. List must be non-empty.
57foldr1 : (a -> a -> a) -> [a] -> a
57foldr1 : (a -> a -> a) -> [a] -> a
58−foldr1 = Native.foldr1
58+foldr1 = Native.List.foldr1
59
59
60-- Reduce a list from the left, building up all of the intermediate results into a list.
60-- Reduce a list from the left, building up all of the intermediate results into a list.
61--
61--
62-- scanl (+) 0 [1,2,3,4] == [0,1,3,6,10]
62-- scanl (+) 0 [1,2,3,4] == [0,1,3,6,10]
63scanl : (a -> b -> b) -> b -> [a] -> [b]
63scanl : (a -> b -> b) -> b -> [a] -> [b]
64−scanl = Native.scanl
64+scanl = Native.List.scanl
65
65
66-- Same as scanl but it doesn't require a base case. List must be non-empty.
66-- Same as scanl but it doesn't require a base case. List must be non-empty.
67--
67--
68-- scanl1 (+) [1,2,3,4] == [1,3,6,10]
68-- scanl1 (+) [1,2,3,4] == [1,3,6,10]
69scanl1 : (a -> a -> a) -> [a] -> [a]
69scanl1 : (a -> a -> a) -> [a] -> [a]
70−scanl1 = Native.scanl1
70+scanl1 = Native.List.scanl1
71
71
72-- Filter out elements which do not satisfy the predicate: `(filter isLower "AaBbCc" == "abc")`
72-- Filter out elements which do not satisfy the predicate: `(filter isLower "AaBbCc" == "abc")`
73filter : (a -> Bool) -> [a] -> [a]
73filter : (a -> Bool) -> [a] -> [a]
74−filter = Native.filter
74+filter = Native.List.filter
75
75
76-- Determine the length of a list: `(length "innumerable" == 11)`
76-- Determine the length of a list: `(length "innumerable" == 11)`
77length : [a] -> Int
77length : [a] -> Int
78−length = Native.length
78+length = Native.List.length
79
79
80-- Reverse a list. `(reverse [1..4] == [4,3,2,1])`
80-- Reverse a list. `(reverse [1..4] == [4,3,2,1])`
81reverse : [a] -> [a]
81reverse : [a] -> [a]
82−reverse = Native.reverse
82+reverse = Native.List.reverse
83
83
84-- Check to see if all elements satisfy the predicate.
84-- Check to see if all elements satisfy the predicate.
85all : (a -> Bool) -> [a] -> Bool
85all : (a -> Bool) -> [a] -> Bool
86−all = Native.all
86+all = Native.List.all
87
87
88-- Check to see if any elements satisfy the predicate.
88-- Check to see if any elements satisfy the predicate.
89any : (a -> Bool) -> [a] -> Bool
89any : (a -> Bool) -> [a] -> Bool
90−any = Native.any
90+any = Native.List.any
91
91
92-- Check to see if all elements are True.
92-- Check to see if all elements are True.
93and : [Bool] -> Bool
93and : [Bool] -> Bool
94−and = Native.and
94+and = Native.List.and
95
95
96-- Check to see if any elements are True.
96-- Check to see if any elements are True.
97or : [Bool] -> Bool
97or : [Bool] -> Bool
98−or = Native.or
98+or = Native.List.or
99
99
100-- Concatenate a list of appendable things:
100-- Concatenate a list of appendable things:
101--
101--
102-- concat ["tree","house"] == "treehouse"
102-- concat ["tree","house"] == "treehouse"
103concat : [appendable] -> appendable
103concat : [appendable] -> appendable
104−concat = Native.concat
104+concat = Native.List.concat
105
105
106-- Map a given function onto a list and flatten the resulting lists.
106-- Map a given function onto a list and flatten the resulting lists.
107--
107--
@@ -139,14 +139,14 @@ partition pred lst =
139-- zip [1,2,3] [6,7] == [(1,6),(2,7)]
139-- zip [1,2,3] [6,7] == [(1,6),(2,7)]
140-- zip == zipWith (,)
140-- zip == zipWith (,)
141zip : [a] -> [b] -> [(a,b)]
141zip : [a] -> [b] -> [(a,b)]
142−zip = Native.zip
142+zip = Native.List.zip
143
143
144-- Combine two lists, combining them with the given function.
144-- Combine two lists, combining them with the given function.
145-- If one list is longer, the extra elements are dropped.
145-- If one list is longer, the extra elements are dropped.
146--
146--
147-- zipWith (+) [1,2,3] [1,2,3,4] == [2,4,6]
147-- zipWith (+) [1,2,3] [1,2,3,4] == [2,4,6]
148zipWith : (a -> b -> c) -> [a] -> [b] -> [c]
148zipWith : (a -> b -> c) -> [a] -> [b] -> [c]
149−zipWith = Native.zipWith
149+zipWith = Native.List.zipWith
150
150
151-- Decompose a list of tuples.
151-- Decompose a list of tuples.
152unzip : [(a,b)] -> ([a],[b])
152unzip : [(a,b)] -> ([a],[b])
@@ -159,14 +159,14 @@ unzip pairs =
159--
159--
160-- split "," "hello,there,friend" == ["hello", "there", "friend"]
160-- split "," "hello,there,friend" == ["hello", "there", "friend"]
161split : [a] -> [a] -> [[a]]
161split : [a] -> [a] -> [[a]]
162−split = Native.split
162+split = Native.List.split
163
163
164-- Places the given value between all of the lists in the second argument
164-- Places the given value between all of the lists in the second argument
165-- and concatenates the result.
165-- and concatenates the result.
166--
166--
167-- join "a" ["H","w","ii","n"] == "Hawaiian"
167-- join "a" ["H","w","ii","n"] == "Hawaiian"
168join : appendable -> [appendable] -> appendable
168join : appendable -> [appendable] -> appendable
169−join = Native.join
169+join = Native.List.join
170
170
171-- Places the given value between all members of the given list.
171-- Places the given value between all members of the given list.
172--
172--
@@ -180,8 +180,8 @@ intersperse sep xs =
180
180
181-- Take the first n members of a list: `(take 2 [1,2,3,4] == [1,2])`
181-- Take the first n members of a list: `(take 2 [1,2,3,4] == [1,2])`
182take : Int -> [a] -> [a]
182take : Int -> [a] -> [a]
183−take = Native.take
183+take = Native.List.take
184
184
185-- Drop the first n members of a list: `(drop 2 [1,2,3,4] == [3,4])`
185-- Drop the first n members of a list: `(drop 2 [1,2,3,4] == [3,4])`
186drop : Int -> [a] -> [a]
186drop : Int -> [a] -> [a]
187−drop = Native.drop
187+drop = Native.List.drop
libraries/Matrix2D.elm+5−5
@@ -1,7 +1,7 @@
1
1
2module Matrix2D where
2module Matrix2D where
3
3
4−import Native.Matrix2D as Native
4+import Native.Matrix2D
5
5
6data Matrix2D = Matrix2D
6data Matrix2D = Matrix2D
7
7
@@ -10,7 +10,7 @@ data Matrix2D = Matrix2D
10-- / 1 0 \\
10-- / 1 0 \\
11-- \\ 0 1 /
11-- \\ 0 1 /
12identity : Matrix2D
12identity : Matrix2D
13−identity = Native.identity
13+identity = Native.Matrix2D.identity
14
14
15-- Creates an arbitrary matrix. This lets you create scales, shears, reflections,
15-- Creates an arbitrary matrix. This lets you create scales, shears, reflections,
16-- translations, or any other 2D transform.
16-- translations, or any other 2D transform.
@@ -22,7 +22,7 @@ identity = Native.identity
22--
22--
23-- And `dx` and `dy` are the translation values.
23-- And `dx` and `dy` are the translation values.
24matrix : Float -> Float -> Float -> Float -> Float -> Float -> Matrix2D
24matrix : Float -> Float -> Float -> Float -> Float -> Float -> Matrix2D
25−matrix = Native.matrix
25+matrix = Native.Matrix2D.matrix
26
26
27-- Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
27-- Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
28-- Given an angle t, it creates a counterclockwise rotation matrix:
28-- Given an angle t, it creates a counterclockwise rotation matrix:
@@ -30,7 +30,7 @@ matrix = Native.matrix
30-- / cos t -sin t \\
30-- / cos t -sin t \\
31-- \\ sin t cos t /
31-- \\ sin t cos t /
32rotation : Float -> Matrix2D
32rotation : Float -> Matrix2D
33−rotation = Native.rotation
33+rotation = Native.Matrix2D.rotation
34
34
35-- Multiplies two matrices together:
35-- Multiplies two matrices together:
36--
36--
@@ -39,4 +39,4 @@ rotation = Native.rotation
39-- / a11 a12 \\ . / b11 b12 \\
39-- / a11 a12 \\ . / b11 b12 \\
40-- \\ a21 a22 / \\ b21 b22 /
40-- \\ a21 a22 / \\ b21 b22 /
41multiply : Matrix2D -> Matrix2D -> Matrix2D
41multiply : Matrix2D -> Matrix2D -> Matrix2D
42−multiply = Native.multiply
42+multiply = Native.Matrix2D.multiply
libraries/Mouse.elm+7−7
@@ -2,30 +2,30 @@
2module Mouse where
2module Mouse where
3
3
4import Signal (Signal)
4import Signal (Signal)
5−import Native.Mouse as Native
5+import Native.Mouse
6
6
7-- The current mouse position.
7-- The current mouse position.
8position : Signal (Int,Int)
8position : Signal (Int,Int)
9−position = Native.position
9+position = Native.Mouse.position
10
10
11-- The current x-coordinate of the mouse.
11-- The current x-coordinate of the mouse.
12x : Signal Int
12x : Signal Int
13−x = Native.x
13+x = Native.Mouse.x
14
14
15-- The current y-coordinate of the mouse.
15-- The current y-coordinate of the mouse.
16y : Signal Int
16y : Signal Int
17−y = Native.y
17+y = Native.Mouse.y
18
18
19-- The current state of the left mouse-button.
19-- The current state of the left mouse-button.
20-- True when the button is down, and false otherwise.
20-- True when the button is down, and false otherwise.
21isDown : Signal Bool
21isDown : Signal Bool
22−isDown = Native.isDown
22+isDown = Native.Mouse.isDown
23
23
24-- True immediately after the left mouse-button has been clicked,
24-- True immediately after the left mouse-button has been clicked,
25-- and false otherwise.
25-- and false otherwise.
26isClicked : Signal Bool
26isClicked : Signal Bool
27−isClicked = Native.isClicked
27+isClicked = Native.Mouse.isClicked
28
28
29-- Always equal to unit. Event triggers on every mouse click.
29-- Always equal to unit. Event triggers on every mouse click.
30clicks : Signal ()
30clicks : Signal ()
31−clicks = Native.clicks
31+clicks = Native.Mouse.clicks
libraries/Native/Basics.js+7−7
@@ -3,10 +3,10 @@ Elm.Native.Basics = function(elm) {
3 'use strict';
3 'use strict';
4 if (elm.Native.Basics) return elm.Native.Basics;
4 if (elm.Native.Basics) return elm.Native.Basics;
5
5
6− var JS = Elm.JavaScript(elm);
6+ var JS = Elm.Native.JavaScript(elm);
7− var Maybe = Elm.Maybe(elm);
7+ // var Maybe = Elm.Maybe(elm);
8 var Utils = Elm.Native.Utils(elm);
8 var Utils = Elm.Native.Utils(elm);
9− var Char = Elm.Char(elm);
9+ //var Char = Elm.Char(elm);
10
10
11 function div(a,b) { return (a/b)|0; }
11 function div(a,b) { return (a/b)|0; }
12 function rem(a,b) { return a % b; }
12 function rem(a,b) { return a % b; }
@@ -26,7 +26,7 @@ Elm.Native.Basics = function(elm) {
26 function uncurry(f,v) { return A2(f,v._0,v._1); }
26 function uncurry(f,v) { return A2(f,v._0,v._1); }
27 function fst(t) { return t._0; }
27 function fst(t) { return t._0; }
28 function snd(t) { return t._1; }
28 function snd(t) { return t._1; }
29−
29+/*
30 function readInt(str) {
30 function readInt(str) {
31 var s = JS.fromString(str);
31 var s = JS.fromString(str);
32 var len = s.length;
32 var len = s.length;
@@ -62,7 +62,7 @@ Elm.Native.Basics = function(elm) {
62 }
62 }
63 return Maybe.Just(parseFloat(s));
63 return Maybe.Just(parseFloat(s));
64 }
64 }
65−
65+*/
66 var basics = {
66 var basics = {
67 div:F2(div),
67 div:F2(div),
68 rem:F2(rem),
68 rem:F2(rem),
@@ -95,8 +95,8 @@ Elm.Native.Basics = function(elm) {
95 round:Math.round,
95 round:Math.round,
96 toFloat:function(x) { return x; },
96 toFloat:function(x) { return x; },
97
97
98− readInt:readInt,
98+ //readInt:readInt,
99− readFloat:readFloat,
99+ //readFloat:readFloat,
100
100
101 curry:F3(curry),
101 curry:F3(curry),
102 uncurry:F2(uncurry),
102 uncurry:F2(uncurry),
libraries/Random.elm+3−3
@@ -2,15 +2,15 @@
2module Random where
2module Random where
3
3
4import Signal (Signal)
4import Signal (Signal)
5−import Native.Random as Native
5+import Native.Random
6
6
7-- Given a range from low to high and a signal of values, this produces
7-- Given a range from low to high and a signal of values, this produces
8-- a new signal that changes whenever the input signal changes. The new
8-- a new signal that changes whenever the input signal changes. The new
9-- values are random number between 'low' and 'high' inclusive.
9-- values are random number between 'low' and 'high' inclusive.
10range : Int -> Int -> Signal a -> Signal Int
10range : Int -> Int -> Signal a -> Signal Int
11−range = Native.range
11+range = Native.Random.range
12
12
13-- Produces a new signal that changes whenever the input signal changes.
13-- Produces a new signal that changes whenever the input signal changes.
14-- The new values are random numbers in [0..1).
14-- The new values are random numbers in [0..1).
15float : Signal a -> Signal Float
15float : Signal a -> Signal Float
16−float = Native.float
16+float = Native.Random.float
libraries/Signal.elm+24−24
@@ -7,7 +7,7 @@
7-- Note: There are lift functions up to `lift8`.
7-- Note: There are lift functions up to `lift8`.
8module Signal where
8module Signal where
9
9
10−import Native.Signal as Native
10+import Native.Signal
11import List (foldr)
11import List (foldr)
12
12
13data Signal a = Signal
13data Signal a = Signal
@@ -16,37 +16,37 @@ data Signal a = Signal
16
16
17-- Create a constant signal that never changes.
17-- Create a constant signal that never changes.
18constant : a -> Signal a
18constant : a -> Signal a
19−constant = Native.constant
19+constant = Native.Signal.constant
20
20
21-- Transform a signal with a given function.
21-- Transform a signal with a given function.
22lift : (a -> b) -> Signal a -> Signal b
22lift : (a -> b) -> Signal a -> Signal b
23−lift = Native.lift
23+lift = Native.Signal.lift
24
24
25-- Combine two signals with a given function.
25-- Combine two signals with a given function.
26lift2 : (a -> b -> c) -> Signal a -> Signal b -> Signal c
26lift2 : (a -> b -> c) -> Signal a -> Signal b -> Signal c
27−lift2 = Native.lift2
27+lift2 = Native.Signal.lift2
28
28
29-- Combine three signals with a given function.
29-- Combine three signals with a given function.
30lift3 : (a -> b -> c -> d) -> Signal a -> Signal b -> Signal c -> Signal d
30lift3 : (a -> b -> c -> d) -> Signal a -> Signal b -> Signal c -> Signal d
31−lift3 = Native.lift3
31+lift3 = Native.Signal.lift3
32
32
33lift4 : (a -> b -> c -> d -> e) -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e
33lift4 : (a -> b -> c -> d -> e) -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e
34−lift4 = Native.lift4
34+lift4 = Native.Signal.lift4
35
35
36lift5 : (a -> b -> c -> d -> e -> f) -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f
36lift5 : (a -> b -> c -> d -> e -> f) -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f
37−lift5 = Native.lift5
37+lift5 = Native.Signal.lift5
38
38
39lift6 : (a -> b -> c -> d -> e -> f -> g)
39lift6 : (a -> b -> c -> d -> e -> f -> g)
40 -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal g
40 -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal g
41−lift6 = Native.lift6
41+lift6 = Native.Signal.lift6
42
42
43lift7 : (a -> b -> c -> d -> e -> f -> g -> h)
43lift7 : (a -> b -> c -> d -> e -> f -> g -> h)
44 -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal g -> Signal h
44 -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal g -> Signal h
45−lift7 = Native.lift7
45+lift7 = Native.Signal.lift7
46
46
47lift8 : (a -> b -> c -> d -> e -> f -> g -> h -> i)
47lift8 : (a -> b -> c -> d -> e -> f -> g -> h -> i)
48 -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal g -> Signal h -> Signal i
48 -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal g -> Signal h -> Signal i
49−lift8 = Native.lift8
49+lift8 = Native.Signal.lift8
50
50
51
51
52-- Create a past-dependent signal. Each value given on the input signal will
52-- Create a past-dependent signal. Each value given on the input signal will
@@ -54,21 +54,21 @@ lift8 = Native.lift8
54--
54--
55-- For instance, `(foldp (\\t acc -> acc + 1) 0 (Time.every second))` increments every second.
55-- For instance, `(foldp (\\t acc -> acc + 1) 0 (Time.every second))` increments every second.
56foldp : (a -> b -> b) -> b -> Signal a -> Signal b
56foldp : (a -> b -> b) -> b -> Signal a -> Signal b
57−foldp = Native.foldp
57+foldp = Native.Signal.foldp
58
58
59-- Merge two signals into one, biased towards the first signal if both signals
59-- Merge two signals into one, biased towards the first signal if both signals
60-- update at the same time.
60-- update at the same time.
61merge : Signal a -> Signal a -> Signal a
61merge : Signal a -> Signal a -> Signal a
62−merge = Native.merge
62+merge = Native.Signal.merge
63
63
64-- Merge many signals into one, biased towards the left-most signal if multiple
64-- Merge many signals into one, biased towards the left-most signal if multiple
65-- signals update simultaneously.
65-- signals update simultaneously.
66merges : [Signal a] -> Signal a
66merges : [Signal a] -> Signal a
67−merges = Native.merges
67+merges = Native.Signal.merges
68
68
69-- Combine a list of signals into a signal of lists.
69-- Combine a list of signals into a signal of lists.
70combine : [Signal a] -> Signal [a]
70combine : [Signal a] -> Signal [a]
71−combine = foldr (Native.lift2 (::)) (Native.constant [])
71+combine = foldr (Native.Signal.lift2 (::)) (Native.Signal.constant [])
72
72
73 -- Merge two signals into one, but distinguishing the values by marking the first
73 -- Merge two signals into one, but distinguishing the values by marking the first
74 -- signal as `Left` and the second signal as `Right`. This allows you to easily
74 -- signal as `Left` and the second signal as `Right`. This allows you to easily
@@ -77,23 +77,23 @@ combine = foldr (Native.lift2 (::)) (Native.constant [])
77
77
78-- Count the number of events that have occured.
78-- Count the number of events that have occured.
79count : Signal a -> Signal Int
79count : Signal a -> Signal Int
80−count = Native.count
80+count = Native.Signal.count
81
81
82-- Count the number of events that have occured that satisfy a given predicate.
82-- Count the number of events that have occured that satisfy a given predicate.
83countIf : (a -> Bool) -> Signal a -> Signal Int
83countIf : (a -> Bool) -> Signal a -> Signal Int
84−countIf = Native.countIf
84+countIf = Native.Signal.countIf
85
85
86-- Keep only events that satisfy the given predicate. Elm does not allow
86-- Keep only events that satisfy the given predicate. Elm does not allow
87-- undefined signals, so a base case must be provided in case the predicate is
87-- undefined signals, so a base case must be provided in case the predicate is
88-- never satisfied.
88-- never satisfied.
89keepIf : (a -> Bool) -> a -> Signal a -> Signal a
89keepIf : (a -> Bool) -> a -> Signal a -> Signal a
90−keepIf = Native.keepIf
90+keepIf = Native.Signal.keepIf
91
91
92-- Drop events that satisfy the given predicate. Elm does not allow undefined
92-- Drop events that satisfy the given predicate. Elm does not allow undefined
93-- signals, so a base case must be provided in case the predicate is never
93-- signals, so a base case must be provided in case the predicate is never
94-- satisfied.
94-- satisfied.
95dropIf : (a -> Bool) -> a -> Signal a -> Signal a
95dropIf : (a -> Bool) -> a -> Signal a -> Signal a
96−dropIf = Native.dropIf
96+dropIf = Native.Signal.dropIf
97
97
98-- Keep events only when the first signal is true. When the first signal becomes
98-- Keep events only when the first signal is true. When the first signal becomes
99-- true, the most recent value of the second signal will be propagated. Until
99-- true, the most recent value of the second signal will be propagated. Until
@@ -101,7 +101,7 @@ dropIf = Native.dropIf
101-- not allow undefined signals, so a base case must be provided in case the first
101-- not allow undefined signals, so a base case must be provided in case the first
102-- signal is never true.
102-- signal is never true.
103keepWhen : Signal Bool -> a -> Signal a -> Signal a
103keepWhen : Signal Bool -> a -> Signal a -> Signal a
104−keepWhen = Native.keepWhen
104+keepWhen = Native.Signal.keepWhen
105
105
106-- Drop events when the first signal is true. When the first signal becomes false,
106-- Drop events when the first signal is true. When the first signal becomes false,
107-- the most recent value of the second signal will be propagated. Until the first
107-- the most recent value of the second signal will be propagated. Until the first
@@ -109,26 +109,26 @@ keepWhen = Native.keepWhen
109-- undefined signals, so a base case must be provided in case the first signal is
109-- undefined signals, so a base case must be provided in case the first signal is
110-- always true.
110-- always true.
111dropWhen : Signal Bool -> a -> Signal a -> Signal a
111dropWhen : Signal Bool -> a -> Signal a -> Signal a
112−dropWhen = Native.dropWhen
112+dropWhen = Native.Signal.dropWhen
113
113
114-- Drop sequential repeated values. For example, if a signal produces the
114-- Drop sequential repeated values. For example, if a signal produces the
115-- sequence `[1,1,2,2,1]`, it becomes `[1,2,1]` by dropping the values that
115-- sequence `[1,1,2,2,1]`, it becomes `[1,2,1]` by dropping the values that
116-- are the same as the previous value.
116-- are the same as the previous value.
117dropRepeats : Signal a -> Signal a
117dropRepeats : Signal a -> Signal a
118−dropRepeats = Native.dropRepeats
118+dropRepeats = Native.Signal.dropRepeats
119
119
120-- Sample from the second input every time an event occurs on the first input.
120-- Sample from the second input every time an event occurs on the first input.
121-- For example, `(sampleOn clicks (every second))` will give the approximate
121-- For example, `(sampleOn clicks (every second))` will give the approximate
122-- time of the latest click.
122-- time of the latest click.
123sampleOn : Signal a -> Signal b -> Signal b
123sampleOn : Signal a -> Signal b -> Signal b
124−sampleOn = Native.sampleOn
124+sampleOn = Native.Signal.sampleOn
125
125
126-- An alias for `lift`. A prettier way to apply a
126-- An alias for `lift`. A prettier way to apply a
127-- function to the current value of a signal.
127-- function to the current value of a signal.
128--
128--
129-- lift f signal == f <~ signal
129-- lift f signal == f <~ signal
130(<~) : (a -> b) -> Signal a -> Signal b
130(<~) : (a -> b) -> Signal a -> Signal b
131−(<~) = Native.lift
131+f <~ s = Native.Signal.lift f s
132
132
133-- Signal application. This takes two signals, holding a function and
133-- Signal application. This takes two signals, holding a function and
134-- a value. It applies the current function to the current value.
134-- a value. It applies the current function to the current value.
@@ -138,4 +138,4 @@ sampleOn = Native.sampleOn
138-- scene <~ Window.dimensions ~ Mouse.position
138-- scene <~ Window.dimensions ~ Mouse.position
139-- lift2 scene Window.dimensions Mouse.position
139-- lift2 scene Window.dimensions Mouse.position
140(~) : Signal (a -> b) -> Signal a -> Signal b
140(~) : Signal (a -> b) -> Signal a -> Signal b
141−(~) = Native.lift2 (\f x -> f x)
141+sf ~ s = Native.Signal.lift2 (\f x -> f x) sf s
libraries/Text.elm+19−19
@@ -6,79 +6,79 @@ import Color (Color)
6import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
6import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
7import Maybe (Maybe)
7import Maybe (Maybe)
8import JavaScript (JSString)
8import JavaScript (JSString)
9−import Native.Text as Native
9+import Native.Text
10
10
11data Text = Text
11data Text = Text
12
12
13-- Convert a string into text which can be styled and displayed.
13-- Convert a string into text which can be styled and displayed.
14toText : String -> Text
14toText : String -> Text
15−toText = Native.toText
15+toText = Native.Text.toText
16
16
17-- Set the typeface of some text. The first argument should be a comma separated listing of the desired typefaces
17-- Set the typeface of some text. The first argument should be a comma separated listing of the desired typefaces
18-- "helvetica, arial, sans-serif"
18-- "helvetica, arial, sans-serif"
19-- Works the same as the CSS font-family property.
19-- Works the same as the CSS font-family property.
20typeface : String -> Text -> Text
20typeface : String -> Text -> Text
21−typeface = Native.typeface
21+typeface = Native.Text.typeface
22
22
23-- Switch to a monospace typeface. Good for code snippets.
23-- Switch to a monospace typeface. Good for code snippets.
24monospace : Text -> Text
24monospace : Text -> Text
25−monospace = Native.monospace
25+monospace = Native.Text.monospace
26
26
27-- Make text big and noticable.
27-- Make text big and noticable.
28header : Text -> Text
28header : Text -> Text
29−header = Native.header
29+header = Native.Text.header
30
30
31-- Create a link.
31-- Create a link.
32link : String -> Text -> Text
32link : String -> Text -> Text
33−link = Native.link
33+link = Native.Text.link
34
34
35-- Set the height of text in pixels.
35-- Set the height of text in pixels.
36height : Float -> Text -> Text
36height : Float -> Text -> Text
37−height = Native.height
37+height = Native.Text.height
38
38
39-- Set the color of a string.
39-- Set the color of a string.
40color : Color -> Text -> Text
40color : Color -> Text -> Text
41−color = Native.color
41+color = Native.Text.color
42
42
43-- Make a string bold.
43-- Make a string bold.
44bold : Text -> Text
44bold : Text -> Text
45−bold = Native.bold
45+bold = Native.Text.bold
46
46
47-- Italicize a string.
47-- Italicize a string.
48italic : Text -> Text
48italic : Text -> Text
49−italic = Native.italic
49+italic = Native.Text.italic
50
50
51-- Draw a line above a string.
51-- Draw a line above a string.
52overline : Text -> Text
52overline : Text -> Text
53−overline = Native.overline
53+overline = Native.Text.overline
54
54
55-- Underline a string.
55-- Underline a string.
56underline : Text -> Text
56underline : Text -> Text
57−underline = Native.underline
57+underline = Native.Text.underline
58
58
59-- Draw a line through a string.
59-- Draw a line through a string.
60strikeThrough : Text -> Text
60strikeThrough : Text -> Text
61−strikeThrough = Native.strikeThrough
61+strikeThrough = Native.Text.strikeThrough
62
62
63-- Display justified, styled text.
63-- Display justified, styled text.
64justified : Text -> Element
64justified : Text -> Element
65−justified = Native.justified
65+justified = Native.Text.justified
66
66
67-- Display centered, styled text.
67-- Display centered, styled text.
68centered : Text -> Element
68centered : Text -> Element
69−centered = Native.centered
69+centered = Native.Text.centered
70
70
71-- Display right justified, styled text.
71-- Display right justified, styled text.
72righted : Text -> Element
72righted : Text -> Element
73−righted = Native.righted
73+righted = Native.Text.righted
74
74
75-- Display styled text.
75-- Display styled text.
76text : Text -> Element
76text : Text -> Element
77−text = Native.text
77+text = Native.Text.text
78
78
79-- Display a plain string.
79-- Display a plain string.
80plainText : String -> Element
80plainText : String -> Element
81−plainText = Native.plainText
81+plainText = Native.Text.plainText
82
82
83-- Convert anything to it's textual representation and make it displayable in browser
83-- Convert anything to it's textual representation and make it displayable in browser
84--
84--
@@ -86,4 +86,4 @@ plainText = Native.plainText
86--
86--
87-- Excellent for debugging.
87-- Excellent for debugging.
88asText : a -> Element
88asText : a -> Element
89−asText = Native.asText
89+asText = Native.Text.asText
libraries/Time.elm+7−7
@@ -2,7 +2,7 @@
2module Time where
2module Time where
3
3
4import open Basics
4import open Basics
5−import Native.Time as Native
5+import Native.Time
6import Signal (Signal)
6import Signal (Signal)
7
7
8-- Type alias to make it clearer when you are working with time values.
8-- Type alias to make it clearer when you are working with time values.
@@ -41,7 +41,7 @@ inHours t = t / hour
41-- the desired FPS. A time delta is the time between the last frame and the
41-- the desired FPS. A time delta is the time between the last frame and the
42-- current frame.
42-- current frame.
43fps : number -> Signal Time
43fps : number -> Signal Time
44−fps = Native.fps
44+fps = Native.Time.fps
45
45
46-- Same as the fps function, but you can turn it on and off. Allows you
46-- Same as the fps function, but you can turn it on and off. Allows you
47-- to do brief animations based on user input without major inefficiencies.
47-- to do brief animations based on user input without major inefficiencies.
@@ -49,12 +49,12 @@ fps = Native.fps
49-- the pause was. This way summing the deltas will actually give the amount
49-- the pause was. This way summing the deltas will actually give the amount
50-- of time that the output signal has been running.
50-- of time that the output signal has been running.
51fpsWhen : number -> Signal Bool -> Signal Time
51fpsWhen : number -> Signal Bool -> Signal Time
52−fpsWhen = Native.fpsWhen
52+fpsWhen = Native.Time.fpsWhen
53
53
54-- Takes a time interval t. The resulting signal is the current time,
54-- Takes a time interval t. The resulting signal is the current time,
55-- updated every t.
55-- updated every t.
56every : Time -> Signal Time
56every : Time -> Signal Time
57−every = Native.every
57+every = Native.Time.every
58
58
59-- Takes a time `t` and any signal. The resulting boolean signal
59-- Takes a time `t` and any signal. The resulting boolean signal
60-- is true for time `t` after every event on the input signal.
60-- is true for time `t` after every event on the input signal.
@@ -62,16 +62,16 @@ every = Native.every
62-- that is true for one second after each mouse click and false
62-- that is true for one second after each mouse click and false
63-- otherwise.
63-- otherwise.
64since : Time -> Signal a -> Signal Bool
64since : Time -> Signal a -> Signal Bool
65−since = Native.since
65+since = Native.Time.since
66
66
67-- Add a timestamp to any signal. Timestamps increase monotonically. Each
67-- Add a timestamp to any signal. Timestamps increase monotonically. Each
68-- timestamp is related to a specfic event, so `Mouse.x` and `Mouse.y` will
68-- timestamp is related to a specfic event, so `Mouse.x` and `Mouse.y` will
69-- always have the same timestamp because they both rely on the same
69-- always have the same timestamp because they both rely on the same
70-- underlying event.
70-- underlying event.
71timestamp : Signal a -> Signal (Time, a)
71timestamp : Signal a -> Signal (Time, a)
72−timestamp = Native.timestamp
72+timestamp = Native.Time.timestamp
73
73
74-- Delay a signal by a certain amount of time. So `(delay second Mouse.clicks)`
74-- Delay a signal by a certain amount of time. So `(delay second Mouse.clicks)`
75-- will update one second later than any mouse click.
75-- will update one second later than any mouse click.
76delay : Time -> Signal a -> Signal a
76delay : Time -> Signal a -> Signal a
77−delay = Native.delay
77+delay = Native.Time.delay
libraries/Touch.elm+3−3
@@ -3,7 +3,7 @@
3module Touch where
3module Touch where
4
4
5import Signal (Signal)
5import Signal (Signal)
6−import Native.Touch as Native
6+import Native.Touch
7import Time (Time)
7import Time (Time)
8
8
9-- Every `Touch` has `xy` coordinates. It also has an identifier `id` to
9-- Every `Touch` has `xy` coordinates. It also has an identifier `id` to
@@ -16,9 +16,9 @@ type Touch = { x:Int, y:Int, id:Int, x0:Int, y0:Int, t0:Time }
16
16
17-- A list of ongoing touches.
17-- A list of ongoing touches.
18touches : Signal [Touch]
18touches : Signal [Touch]
19−touches = Native.touches
19+touches = Native.Touch.touches
20
20
21-- The last position that was tapped. Default value is `{x=0,y=0}`.
21-- The last position that was tapped. Default value is `{x=0,y=0}`.
22-- Updates whenever the user taps the screen.
22-- Updates whenever the user taps the screen.
23taps : Signal { x:Int, y:Int }
23taps : Signal { x:Int, y:Int }
24−taps = Native.taps
24+taps = Native.Touch.taps
libraries/WebSocket.elm+2−2
@@ -4,13 +4,13 @@ module WebSocket where
4
4
5import Signal (Signal)
5import Signal (Signal)
6import Basics (String)
6import Basics (String)
7−import Native.WebSocket as Native
7+import Native.WebSocket
8
8
9-- Create a web-socket. The first argument is the URL of the desired
9-- Create a web-socket. The first argument is the URL of the desired
10-- web-socket server. The input signal holds the outgoing messages,
10-- web-socket server. The input signal holds the outgoing messages,
11-- and the resulting signal contains the incoming ones.
11-- and the resulting signal contains the incoming ones.
12connect : String -> Signal String -> Signal String
12connect : String -> Signal String -> Signal String
13−connect = Native.connect
13+connect = Native.WebSocket.connect
14
14
15-- data Action = Open String | Close String | Send String String
15-- data Action = Open String | Close String | Send String String
16-- connections : Signal Action -> Signal String
16-- connections : Signal Action -> Signal String
libraries/Window.elm+4−4
@@ -2,17 +2,17 @@
2module Window where
2module Window where
3
3
4import Signal (Signal)
4import Signal (Signal)
5−import Native.Window as Native
5+import Native.Window
6
6
7-- The current dimensions of the window (i.e. the area viewable to the
7-- The current dimensions of the window (i.e. the area viewable to the
8-- user, not including scroll bars).
8-- user, not including scroll bars).
9dimensions : Signal (Int,Int)
9dimensions : Signal (Int,Int)
10−dimensions = Native.dimensions
10+dimensions = Native.Window.dimensions
11
11
12-- The current width of the window.
12-- The current width of the window.
13width : Signal Int
13width : Signal Int
14−width = Native.width
14+width = Native.Window.width
15
15
16-- The current height of the window.
16-- The current height of the window.
17height : Signal Int
17height : Signal Int
18−height = Native.height
18+height = Native.Window.height