on master help sign in
Fix libraries to match new JS generation rules
commit3e4773ca2ea8f92ea1964208763f8bcc64ce0b12 authorEvan Czaplicki <info@elm-lang.org> dateMon 29 Jul 2013, 23:23 (13 years ago) parent2d4afca
24 files changed+253−264
libraries/Basics.elm+51−51 libraries/Char.elm+12−12 libraries/Color.elm+4−4 libraries/Date.elm+10−10 libraries/Dict.elm+5−5 libraries/Graphics/Collage.elm+2−2 libraries/Graphics/Element.elm+4−15 libraries/Graphics/Input.elm+16−16 libraries/Http.elm+2−2 libraries/JavaScript.elm+13−13 libraries/JavaScript/Experimental.elm+3−3 libraries/Json.elm+7−7 libraries/Keyboard.elm+16−16 libraries/List.elm+27−27 libraries/Matrix2D.elm+5−5 libraries/Mouse.elm+7−7 libraries/Native/Basics.js+7−7 libraries/Random.elm+3−3 libraries/Signal.elm+24−24 libraries/Text.elm+19−19 libraries/Time.elm+7−7 libraries/Touch.elm+3−3 libraries/WebSocket.elm+2−2 libraries/Window.elm+4−4
libraries/Basics.elm+51−51
@@ -1,7 +1,7 @@
11
22module Basics where
33
4−import Native.Basics as Native
4+import Native.Basics
55
66type String = [Char]
77
@@ -11,72 +11,72 @@ radians t = t
1111
1212-- Convert degrees to standard Elm angles (radians).
1313degrees : Float -> Float
14−degrees d = d * Native.pi / 180
14+degrees d = d * Native.Basics.pi / 180
1515
1616-- Convert turns to standard Elm angles (radians).
1717-- One turn is equal to 360&deg;.
1818turns : Float -> Float
19−turns r = 2 * Native.pi * r
19+turns r = 2 * Native.Basics.pi * r
2020
2121-- Start with polar coordinates (r,&theta;)
2222-- and get out cartesian coordinates (x,y).
2323fromPolar : (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)
2525
2626-- Start with cartesian coordinates (x,y)
2727-- and get out polar coordinates (r,&theta;).
2828toPolar : (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)
3030
3131(+) : number -> number -> number
32−(+) = Native.add
32+(+) = Native.Basics.add
3333
3434(-) : number -> number -> number
35−(-) = Native.sub
35+(-) = Native.Basics.sub
3636
3737(*) : number -> number -> number
38−(*) = Native.mul
38+(*) = Native.Basics.mul
3939
4040-- Floating point division.
4141(/) : Float -> Float -> Float
42−(/) = Native.floatDiv
42+(/) = Native.Basics.floatDiv
4343
4444-- Integer division, remainder is discarded.
4545div : Int -> Int -> Int
46−div = Native.div
46+div = Native.Basics.div
4747
4848-- Finds the remainder after dividing one number by another: ``4 `rem` 3 == 1``
4949rem : Int -> Int -> Int
50−rem = Native.rem
50+rem = Native.Basics.rem
5151
5252-- Perform modular arithmetic: ``7 `mod` 2 == 1``
5353mod : Int -> Int -> Int
54−mod = Native.mod
54+mod = Native.Basics.mod
5555
5656-- Exponentiation: `3^2 == 9`
5757(^) : number -> number -> number
58−(^) = Native.exp
58+(^) = Native.Basics.exp
5959
6060cos : Float -> Float
61−cos = Native.cos
61+cos = Native.Basics.cos
6262
6363sin : Float -> Float
64−sin = Native.sin
64+sin = Native.Basics.sin
6565
6666tan : Float -> Float
67−tan = Native.tan
67+tan = Native.Basics.tan
6868
6969acos : Float -> Float
70−acos = Native.acos
70+acos = Native.Basics.acos
7171
7272asin : Float -> Float
73−asin = Native.asin
73+asin = Native.Basics.asin
7474
7575-- You probably do not want to use this. Because it takes `(y/x)` as the argument
7676-- there is no way to know where the negative signs come from so the resulting
7777-- angle is always between &pi;/2 and -&pi;/2 (in quadrants I and IV).
7878atan : Float -> Float
79−atan = Native.atan
79+atan = Native.Basics.atan
8080
8181-- This helps you find the angle of a cartesian coordinate.
8282-- You will almost certainly want to use this instead of `atan`.
@@ -84,27 +84,27 @@ atan = Native.atan
8484-- quadrant the angle should really be in. The result will be between
8585-- &pi; and -&pi;, giving you the full range of angles.
8686atan2 : Float -> Float -> Float
87−atan2 = Native.atan2
87+atan2 = Native.Basics.atan2
8888
8989-- Take the square root of a number.
9090sqrt : number -> number
91−sqrt = Native.sqrt
91+sqrt = Native.Basics.sqrt
9292
9393-- Take the absolute value of a number.
9494abs : number -> number
95−abs = Native.abs
95+abs = Native.Basics.abs
9696
9797-- Calculate the logarithm of a number with a given base: `logBase 10 100 == 2`
9898logBase : number -> number -> number
99−logBase = Native.logBase
99+logBase = Native.Basics.logBase
100100
101101-- Given two comparables, returns the smaller one.
102102min : comparable -> comparable -> comparable
103−min = Native.min
103+min = Native.Basics.min
104104
105105-- Given two comparables, returns the larger one.
106106max : comparable -> comparable -> comparable
107−max = Native.max
107+max = Native.Basics.max
108108
109109-- Clamps a number within a given range. With the expression `clamp 100 200 x`
110110-- the results are as follows:
@@ -113,40 +113,40 @@ max = Native.max
113113-- * ` x if 100 <= x < 200`
114114-- * `200 if 200 <= x`
115115clamp : number -> number -> number -> number
116−clamp = Native.clamp
116+clamp = Native.Basics.clamp
117117
118118-- An approximation of pi.
119119pi : Float
120−pi = Native.pi
120+pi = Native.Basics.pi
121121
122122-- An approximation of e.
123123e : Float
124−e = Native.e
124+e = Native.Basics.e
125125
126126-- Compare any two values for structural equality. Functions cannot be compared.
127127(==) : a -> a -> Bool
128−(==) = Native.eq
128+(==) = Native.Basics.eq
129129
130130(/=) : a -> a -> Bool
131−(/=) = Native.neq
131+(/=) = Native.Basics.neq
132132
133133(<) : comparable -> comparable -> Bool
134−(<) = Native.lt
134+(<) = Native.Basics.lt
135135
136136(>) : comparable -> comparable -> Bool
137−(>) = Native.gt
137+(>) = Native.Basics.gt
138138
139139(<=) : comparable -> comparable -> Bool
140−(<=) = Native.le
140+(<=) = Native.Basics.le
141141
142142(>=) : comparable -> comparable -> Bool
143−(>=) = Native.ge
143+(>=) = Native.Basics.ge
144144
145145-- Compare any two comparable values. Comparable values include `String`, `Char`,
146146-- `Int`, `Float`, `Time`, or a list or tuple containing comparable values.
147147-- These are also the only values that work as `Dict` keys or `Set` members.
148148compare : comparable -> comparable -> Order
149−compare = Native.compare
149+compare = Native.Basics.compare
150150
151151-- Represents the relative ordering of two things.
152152-- The relations are less than, equal to, and greater than.
@@ -154,19 +154,19 @@ data Order = LT | EQ | GT
154154
155155-- The and operator. True if both inputs are True.
156156(&&) : Bool -> Bool -> Bool
157−(&&) = Native.and
157+(&&) = Native.Basics.and
158158
159159-- The or operator. True if one or both inputs are True.
160160(||) : Bool -> Bool -> Bool
161−(||) = Native.or
161+(||) = Native.Basics.or
162162
163163-- The exclusive-or operator. True if exactly one input is True.
164164xor : Bool -> Bool -> Bool
165−xor = Native.xor
165+xor = Native.Basics.xor
166166
167167-- Negate a boolean value: `(not True == False)` and `(not False == True)`
168168not : Bool -> Bool
169−not = Native.not
169+not = Native.Basics.not
170170
171171-- Equal to true. Useful as the last case of a multi-way-if.
172172otherwise : Bool
@@ -177,35 +177,35 @@ otherwise = True
177177
178178-- Round a number to the nearest integer.
179179round : Float -> Int
180−round = Native.round
180+round = Native.Basics.round
181181
182182-- Truncate a decimal number, rounding towards zero.
183183truncate : Float -> Int
184−truncate = Native.truncate
184+truncate = Native.Basics.truncate
185185
186186-- Floor function, rounding down.
187187floor : Float -> Int
188−floor = Native.floor
188+floor = Native.Basics.floor
189189
190190-- Ceiling function, rounding up.
191191ceiling : Float -> Int
192−ceiling = Native.ceiling
192+ceiling = Native.Basics.ceiling
193193
194194-- Convert an integer into a float.
195195toFloat : Int -> Float
196−toFloat = Native.toFloat
196+toFloat = Native.Basics.toFloat
197197
198198-- Convert almost any value to its string representation.
199199show : a -> String
200−show = Native.show
200+show = Native.Basics.show
201201
202202-- Read an integer from a string
203203-- readInt : String -> Maybe Int
204−readInt = Native.readInt
204+--readInt = Native.Basics.readInt
205205
206206-- Read a float from a string.
207207-- readFloat : String -> Maybe Float
208−readFloat = Native.readFloat
208+--readFloat = Native.Basics.readFloat
209209
210210-- Function Helpers
211211
@@ -244,11 +244,11 @@ id x = x
244244
245245-- Given a 2-tuple, returns the first value.
246246fst : (a,b) -> a
247−fst = Native.fst
247+fst = Native.Basics.fst
248248
249249-- Given a 2-tuple, returns the second value.
250250snd : (a,b) -> b
251−snd = Native.snd
251+snd = Native.Basics.snd
252252
253253-- Flips the order of the first two arguments to a function.
254254flip : (a -> b -> c) -> (b -> a -> c)
@@ -257,9 +257,9 @@ flip f b a = f a b
257257-- Change how arguments are passed to a function. This splits paired arguments
258258-- into two separate arguments.
259259curry : ((a,b) -> c) -> a -> b -> c
260−curry = Native.curry
260+curry = Native.Basics.curry
261261
262262-- Change how arguments are passed to a function. This combines two arguments
263263-- into a sigle pair.
264264uncurry : (a -> b -> c) -> (a,b) -> c
265−uncurry = Native.uncurry
265+uncurry = Native.Basics.uncurry
libraries/Char.elm+12−12
@@ -1,50 +1,50 @@
11
22module Char where
33
4−import Native.Char as Native
4+import Native.Char
55
66-- True for upper case letters.
77isUpper : Char -> Bool
8−isUpper = Native.isUpper
8+isUpper = Native.Char.isUpper
99
1010-- True for lower case letters.
1111isLower : Char -> Bool
12−isLower = Native.isLower
12+isLower = Native.Char.isLower
1313
1414-- True for ASCII digits (`0..9`).
1515isDigit : Char -> Bool
16−isDigit = Native.isDigit
16+isDigit = Native.Char.isDigit
1717
1818-- True for ASCII octal digits (`0..7`).
1919isOctDigit : Char -> Bool
20−isOctDigit = Native.isOctDigit
20+isOctDigit = Native.Char.isOctDigit
2121
2222-- True for ASCII hexadecimal digits (`0..9a..fA..F`).
2323isHexDigit : Char -> Bool
24−isHexDigit = Native.isHexDigit
24+isHexDigit = Native.Char.isHexDigit
2525
2626-- Convert to upper case.
2727toUpper : Char -> Char
28−toUpper = Native.toUpper
28+toUpper = Native.Char.toUpper
2929
3030-- Convert to lower case.
3131toLower : Char -> Char
32−toLower = Native.toLower
32+toLower = Native.Char.toLower
3333
3434-- Convert to upper case, according to any locale-specific case mappings.
3535toLocaleUpper : Char -> Char
36−toLocaleUpper = Native.toLocaleUpper
36+toLocaleUpper = Native.Char.toLocaleUpper
3737
3838-- Convert to lower case, according to any locale-specific case mappings.
3939toLocaleLower : Char -> Char
40−toLocaleLower = Native.toLocaleLower
40+toLocaleLower = Native.Char.toLocaleLower
4141
4242type KeyCode = Int
4343
4444-- Convert to unicode.
4545toCode : Char -> KeyCode
46−toCode = Native.toCode
46+toCode = Native.Char.toCode
4747
4848-- Convert from unicode.
4949fromCode : KeyCode -> Char
50−fromCode = Native.fromCode
50+fromCode = Native.Char.fromCode
libraries/Color.elm+4−4
@@ -1,7 +1,7 @@
11
22module Color where
33
4−import Native.Color as Native
4+import Native.Color
55
66data Color = Color Int Int Int Float
77
@@ -58,19 +58,19 @@ forestGreen = Color 34 139 34 1
5858-- Produce a &ldquo;complementary color&rdquo;.
5959-- The two colors will accent each other.
6060complement : Color -> Color
61−complement = Native.complement
61+complement = Native.Color.complement
6262
6363-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV)
6464-- with an alpha component for transparency.
6565hsva : Float -> Float -> Float -> Float -> Color
66−hsva = Native.hsva
66+hsva = Native.Color.hsva
6767
6868-- Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV).
6969-- This is very convenient for creating colors that cycle and shift.
7070--
7171-- hsv (degrees 240) 1 1 == blue
7272hsv : Float -> Float -> Float -> Color
73−hsv = Native.hsv
73+hsv = Native.Color.hsv
7474
7575data Gradient
7676 = Linear (Float,Float) (Float,Float) [(Float,Color)]
libraries/Date.elm+10−10
@@ -5,7 +5,7 @@
55module Date where
66
77import Basics (String)
8−import Native.Date as Native
8+import Native.Date
99import Time (Time)
1010import Maybe (Maybe)
1111
@@ -21,45 +21,45 @@ data Month = Jan | Feb | Mar | Apr
2121
2222-- Attempt to read a date from a string.
2323read : String -> Maybe Date
24−read = Native.read
24+read = Native.Date.read
2525
2626-- Convert a date into a time since midnight (UTC) of 1 January 1990 (i.e.
2727-- [UNIX time](http://en.wikipedia.org/wiki/Unix_time)). Given the date 23 June
2828-- 1990 at 11:45AM this returns the corresponding time.
2929toTime : Date -> Time
30−toTime = Native.toTime
30+toTime = Native.Date.toTime
3131
3232-- Extract the year of a given date. Given the date 23 June 1990 at 11:45AM
3333-- this returns the integer `1990`.
3434year : Date -> Int
35−year = Native.year
35+year = Native.Date.year
3636
3737-- Extract the month of a given date. Given the date 23 June 1990 at 11:45AM
3838-- this returns the Month `Jun` as defined below.
3939month : Date -> Month
40−month = Native.month
40+month = Native.Date.month
4141
4242-- Extract the day of a given date. Given the date 23 June 1990 at 11:45AM
4343-- this returns the integer `23`.
4444day : Date -> Int
45−day = Native.day
45+day = Native.Date.day
4646
4747-- Extract the day of the week for a given date. Given the date 23 June
4848-- 1990 at 11:45AM this returns the Day `Thu` as defined below.
4949dayOfWeek : Date -> Day
50−dayOfWeek = Native.dayOfWeek
50+dayOfWeek = Native.Date.dayOfWeek
5151
5252-- Extract the hour of a given date. Given the date 23 June 1990 at 11:45AM
5353-- this returns the integer `11`.
5454hour : Date -> Int
55−hour = Native.hour
55+hour = Native.Date.hour
5656
5757-- Extract the minute of a given date. Given the date 23 June 1990 at 11:45AM
5858-- this returns the integer `45`.
5959minute : Date -> Int
60−minute = Native.minute
60+minute = Native.Date.minute
6161
6262-- Extract the second of a given date. Given the date 23 June 1990 at 11:45AM
6363-- this returns the integer `0`.
6464second : Date -> Int
65−second = Native.second
65+second = Native.Date.second
libraries/Dict.elm+5−5
@@ -12,7 +12,7 @@ import open Basics
1212import open Maybe
1313import Native.Error
1414import List as List
15−import Native.Utils (compare)
15+import Native.Utils
1616
1717data NColor = Red | Black
1818
@@ -122,7 +122,7 @@ lookup k t =
122122 case t of
123123 RBEmpty -> Nothing
124124 RBNode _ k' v l r ->
125− case compare k k' of
125+ case Native.Utils.compare k k' of
126126 LT -> lookup k l
127127 EQ -> Just v
128128 GT -> lookup k r
@@ -134,7 +134,7 @@ findWithDefault base k t =
134134 case t of
135135 RBEmpty -> base
136136 RBNode _ k' v l r ->
137− case compare k k' of
137+ case Native.Utils.compare k k' of
138138 LT -> findWithDefault base k l
139139 EQ -> v
140140 GT -> findWithDefault base k r
@@ -145,7 +145,7 @@ find k t =
145145 case t of
146146 { RBEmpty -> Native.Error.raise "Key was not found in dictionary!"
147147 ; RBNode _ k' v l r ->
148− case compare k k' of
148+ case Native.Utils.compare k k' of
149149 { LT -> find k l
150150 ; EQ -> v
151151 ; GT -> find k r }
@@ -216,7 +216,7 @@ insert k v t = -- Invariant: t is a valid left-leaning rb tree
216216 case t of
217217 RBEmpty -> RBNode Red k v RBEmpty RBEmpty
218218 RBNode c k' v' l r ->
219− let h = case compare k k' of
219+ let h = case Native.Utils.compare k k' of
220220 LT -> RBNode c k' v' (ins l) r
221221 EQ -> RBNode c k' v l r -- replace
222222 GT -> RBNode c k' v' l (ins r)
libraries/Graphics/Collage.elm+2−2
@@ -5,7 +5,7 @@ import open Basics
55import List
66import Either (Either, Left, Right)
77import Matrix2D (Matrix2D, identity)
8−import Native.Graphics.Collage as Native
8+import Native.Graphics.Collage
99import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
1010import Color (Color, black, Gradient)
1111import Maybe (Maybe)
@@ -158,7 +158,7 @@ opacity a f = { f | alpha <- a }
158158-- A collage is a collection of 2D forms. There are no strict positioning
159159-- relationships between forms, so you are free to do all kinds of 2D graphics.
160160collage : Int -> Int -> [Form] -> Element
161−collage = Native.collage
161+collage = Native.Graphics.Collage.collage
162162
163163
164164type Path = [(Float,Float)]
libraries/Graphics/Element.elm+4−15
@@ -1,19 +1,8 @@
11
2−module Graphics.Element (widthOf, heightOf, sizeOf,
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
2+module Graphics.Element where
143
154import open Basics
16−import Native.Utils as Native
5+import Native.Utils
176import open JavaScript
187import List as List
198import open Color
@@ -49,7 +38,7 @@ width : Int -> Element -> Element
4938width nw e = let p = e.props
5039 props = case e.element of
5140 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}
5342 _ -> p
5443 in { element=e.element, props={ props | width <- nw } }
5544
@@ -91,7 +80,7 @@ link href e = let p = e.props in
9180
9281emptyStr = fromString ""
9382newElement 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 }
9584
9685data ElementPrim
9786 = Image ImageStyle Int Int JSString
libraries/Graphics/Input.elm+16−16
@@ -3,7 +3,7 @@ module Graphics.Input where
33
44import Basics (String)
55import Signal (Signal,lift,dropRepeats)
6−import Native.Graphics.Input as Native
6+import Native.Graphics.Input
77import List
88import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
99import Color (Color)
@@ -22,13 +22,13 @@ id x = x
2222-- The `a` value is sent to `events` whenever the button is pressed.
2323buttons : a -> { events : Signal a,
2424 button : a -> String -> Element }
25−buttons = Native.buttons
25+buttons = Native.Graphics.Input.buttons
2626
2727-- Create a button with a given label. The result is an `Element` and
2828-- a signal of units. This signal triggers whenever the button is pressed.
2929button : String -> (Element, Signal ())
3030button txt =
31− let pool = Native.buttons ()
31+ let pool = buttons ()
3232 in (pool.button () txt, pool.events)
3333
3434-- Create a group of custom buttons.
@@ -42,14 +42,14 @@ button txt =
4242-- The `a` value is sent to `events` whenever the button is pressed.
4343customButtons : a -> { events : Signal a,
4444 customButton : a -> Element -> Element -> Element -> Element }
45−customButtons = Native.customButtons
45+customButtons = Native.Graphics.Input.customButtons
4646
4747-- Create a button with custom states for up, hovering, and down
4848-- (given in that order). The result is an `Element` and
4949-- a signal of units. This signal triggers whenever the button is pressed.
5050customButton : Element -> Element -> Element -> (Element, Signal ())
5151customButton up hover down =
52− let pool = Native.customButtons ()
52+ let pool = customButtons ()
5353 in (pool.customButton () up hover down, pool.events)
5454
5555-- Create a group of checkboxes.
@@ -64,7 +64,7 @@ customButton up hover down =
6464-- lets you add an ID to distinguish between checkboxes.
6565checkboxes : a -> { events : Signal a,
6666 checkbox : (Bool -> a) -> Bool -> Element }
67−checkboxes = Native.checkboxes
67+checkboxes = Native.Graphics.Input.checkboxes
6868
6969-- Create a checkbox with a given start state. Unlike `button`, this result
7070-- is a *signal* of elements. That is because a checkbox has state that
@@ -72,16 +72,16 @@ checkboxes = Native.checkboxes
7272-- The boolean signal represents the current state of the checkbox.
7373checkbox : Bool -> (Signal Element, Signal Bool)
7474checkbox b =
75− let cbs = Native.checkboxes b
76− in (lift (cbs.box id) cbs.events, cbs.events)
75+ let cbs = checkboxes b
76+ in (lift (cbs.checkbox id) cbs.events, cbs.events)
7777
7878hoverables : a -> { events : Signal a,
7979 hoverable : (Bool -> a) -> Element -> Element }
80−hoverables = Native.hoverables
80+hoverables = Native.Graphics.Input.hoverables
8181
8282hoverable : Element -> (Element, Signal Bool)
8383hoverable elem =
84− let pool = Native.hoverables False
84+ let pool = hoverables False
8585 in (pool.hoverable id elem, pool.events)
8686
8787-- Represents the current state of a text field. The `string` represents the
@@ -107,7 +107,7 @@ type FieldState = { string:String, selectionStart:Int, selectionEnd:Int }
107107-- lets you add an ID to distinguish between input fields.
108108fields : a -> { events : Signal a,
109109 field : (FieldState -> a) -> String -> FieldState -> Element }
110−fields = Native.fields
110+fields = Native.Graphics.Input.fields
111111
112112-- The empty field state:
113113--
@@ -120,7 +120,7 @@ emptyFieldState = { string="", selectionStart=0, selectionEnd=0 }
120120-- content of the field.
121121field : String -> (Signal Element, Signal String)
122122field placeHolder =
123− let tfs = Native.fields emptyFieldState
123+ let tfs = fields emptyFieldState
124124 changes = dropRepeats tfs.events
125125 in (lift (tfs.field id placeHolder) changes,
126126 dropRepeats (lift .string changes))
@@ -128,7 +128,7 @@ field placeHolder =
128128-- Same as `field` but the UI element blocks out each characters.
129129password : String -> (Signal Element, Signal String)
130130password placeHolder =
131− let tfs = Native.passwords emptyFieldState
131+ let tfs = Native.Graphics.Input.passwords emptyFieldState
132132 changes = dropRepeats tfs.events
133133 in (lift (tfs.field id placeHolder) changes,
134134 dropRepeats (lift .string changes))
@@ -138,7 +138,7 @@ password placeHolder =
138138-- get a custom keyboard with an `@` and `.com` button.
139139email : String -> (Signal Element, Signal String)
140140email placeHolder =
141− let tfs = Native.emails emptyFieldState
141+ let tfs = Native.Graphics.Input.emails emptyFieldState
142142 changes = dropRepeats tfs.events
143143 in (lift (tfs.field id placeHolder) changes,
144144 dropRepeats (lift .string changes))
@@ -148,10 +148,10 @@ email placeHolder =
148148-- value. This lets you avoid manually mapping the string onto
149149-- functions and values.
150150dropDown : [(String,a)] -> (Signal Element, Signal a)
151−dropDown = Native.dropDown
151+dropDown = Native.Graphics.Input.dropDown
152152
153153-- Create a drop-down menu for selecting strings. The resulting
154154-- signal of strings represents the string that is currently selected.
155155stringDropDown : [String] -> (Signal Element, Signal String)
156156stringDropDown 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
66
77import open Basics
88import open Signal
9−import Native.Http as Native
9+import Native.Http
1010
1111-- The datatype for responses. Success contains only the returned message.
1212-- Failures contain both an error code and an error message.
@@ -36,7 +36,7 @@ post url body = Request "POST" url body []
3636-- Performs an HTTP request with the given requests. Produces a signal
3737-- that carries the responses.
3838send : Signal (Request a) -> Signal (Response String)
39−send = Native.send
39+send = Native.Http.send
4040
4141-- Performs an HTTP GET request with the given urls. Produces a signal
4242-- that carries the responses.
libraries/JavaScript.elm+13−13
@@ -1,7 +1,7 @@
11
22module JavaScript where
33
4−import Native.JavaScript as Native
4+import Native.JavaScript
55import open Basics
66
77data JSNumber = JSNumber
@@ -13,44 +13,44 @@ data JSObject = JSObject
1313
1414-- Requires that the input array be uniform (all members have the same type)
1515toList : JSArray a -> [a]
16−toList = Native.toList
16+toList = Native.JavaScript.toList
1717
1818toInt : JSNumber -> Int
19−toInt = Native.toInt
19+toInt = Native.JavaScript.toInt
2020
2121toFloat : JSNumber -> Float
22−toFloat = Native.toFloat
22+toFloat = Native.JavaScript.toFloat
2323
2424toBool : JSBool -> Bool
25−toBool = Native.toBool
25+toBool = Native.JavaScript.toBool
2626
2727toString : JSString -> String
28−toString = Native.toString
28+toString = Native.JavaScript.toString
2929
3030
3131-- Produces a uniform JavaScript array with all members of the same type.
3232fromList : [a] -> JSArray a
33−fromList = Native.fromList
33+fromList = Native.JavaScript.fromList
3434
3535fromInt : Int -> JSNumber
36−fromInt = Native.fromInt
36+fromInt = Native.JavaScript.fromInt
3737
3838fromFloat : Float -> JSNumber
39−fromFloat = Native.fromFloat
39+fromFloat = Native.JavaScript.fromFloat
4040
4141fromBool : Bool -> JSBool
42−fromBool = Native.fromBool
42+fromBool = Native.JavaScript.fromBool
4343
4444fromString : String -> JSString
45−fromString = Native.fromString
45+fromString = Native.JavaScript.fromString
4646
4747{--
4848-- Turn an `Element` into a plain old DOM node.
4949fromElement : Element -> JSDomNode
50−fromElement = Native.fromElement
50+fromElement = Native.JavaScript.fromElement
5151
5252-- Turn a DOM node into an `Element`. You can resize the node
5353-- using the normal `width` and `height` functions.
5454toElement : Int -> Int -> JSDomNode -> Element
55−toElement = Native.toElement
55+toElement = Native.JavaScript.toElement
5656--}
libraries/JavaScript/Experimental.elm+3−3
@@ -2,7 +2,7 @@
22module JavaScript.Experimental where
33
44import JavaScript (JSObject)
5−import Native.JavaScript as Native
5+import Native.JavaScript
66
77-- Turn arbitrary JavaScript objects into Elm records.
88-- Arrays are converted into lists, nested objects are allowed.
@@ -16,7 +16,7 @@ import Native.JavaScript as Native
1616-- { answer:null }
1717-- { info:[true,42,'what'] }
1818toRecord : JSObject -> a
19−toRecord = Native.toRecord
19+toRecord = Native.JavaScript.toRecord
2020
2121-- Turn arbitrary Elm records into JavaScript objects.
2222-- Lists become arrays, nested records are allowed. No ADTs.
@@ -29,4 +29,4 @@ toRecord = Native.toRecord
2929-- { answer = Nothing }
3030-- { result = Left "An error occurred" }
3131fromRecord : a -> JSObject
32−fromRecord = Native.fromRecord
32+fromRecord = Native.JavaScript.fromRecord
libraries/Json.elm+7−7
@@ -7,7 +7,7 @@ import open Basics
77import Dict
88import Maybe (Maybe)
99import JavaScript as JS
10−import Native.Json as Native
10+import Native.Json
1111import JavaScript (JSObject, JSString)
1212
1313-- This datatype can represent all valid values that can be held in a JSON
@@ -28,27 +28,27 @@ data JsonValue
2828-- The first argument is a separator token (e.g. \" \", \"\\n\", etc.) that will
2929-- be used for indentation in the prettified string version of the JSON.
3030toString : String -> JsonValue -> String
31−toString sep v = JS.toString (Native.toJSString sep v)
31+toString sep v = JS.toString (Native.Json.toJSString sep v)
3232
3333-- Convert a proper JSON object into a JavaScript string.
3434-- Note that the type JSString seen here is not the same as the type constructor
3535-- JsonString used elsewhere in this module.
3636toJSString : String -> JsonValue -> JSString
37−toJSString = Native.toJSString
37+toJSString = Native.Json.toJSString
3838
3939-- Parse a string representation of a proper JSON object into
4040-- its Elm representation.
4141fromString : String -> Maybe JsonValue
42−fromString s = Native.fromJSString (JS.fromString s)
42+fromString s = Native.Json.fromJSString (JS.fromString s)
4343
4444-- Parse a JavaScript string representation of a proper JSON object into
4545-- its Elm representation.
4646fromJSString : JSString -> Maybe JsonValue
47−fromJSString = Native.fromJSString
47+fromJSString = Native.Json.fromJSString
4848
4949-- Convert a JS object into a `JsonValue`.
5050fromJSObject : JSObject -> JsonValue
51−fromJSObject = Native.fromJSObject
51+fromJSObject = Native.Json.fromJSObject
5252
5353-- Convert a `JsonValue` into a `JSObject`. Paired with the
5454-- [`JavaScript.Experimental` library](/docs/JavaScript/Experimental.elm),
@@ -61,7 +61,7 @@ fromJSObject = Native.fromJSObject
6161-- Just jsonValue -> Just (JS.toRecord (toJSObject jsonValue))
6262-- Nothing -> Nothing
6363toJSObject : JsonValue -> JSObject
64−toJSObject = Native.toJSObject
64+toJSObject = Native.Json.toJSObject
6565
6666 {-- Extract Elm values from Json values
6767
libraries/Keyboard.elm+16−16
@@ -1,13 +1,19 @@
11module Keyboard where
22
33import Signal (Signal)
4−import Native.Keyboard as Native
4+import Native.Keyboard
55
66-- Type alias to make it clearer what integers are supposed to represent
77-- in this library. Use [`Char.toCode`](docs/Char.elm#toCode) and
88-- [`Char.fromCode`](/docs/Char.elm#fromCode) to convert key codes to characters.
99type KeyCode = Int
1010
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+
1117-- A signal of records indicating which arrow keys are pressed.
1218--
1319-- `{ x = 0, y = 0 }` when pressing no arrows.<br>
@@ -15,43 +21,37 @@ type KeyCode = Int
1521-- `{ x = 1, y = 1 }` when pressing the up and right arrows.<br>
1622-- `{ x = 0, y =-1 }` when pressing the down, left, and right arrows.
1723arrows : Signal { x:Int, y:Int }
18−arrows = Native.directions 38 40 37 39
24+arrows = directions 38 40 37 39
1925
2026-- Just like the arrows signal, but this uses keys w, a, s, and d,
2127-- which are common controls for many computer games.
2228wasd : Signal { x:Int, y:Int }
23−wasd = Native.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
29+wasd = directions 87 83 65 68
3030
3131-- Whether an arbitrary key is pressed.
3232isDown : KeyCode -> Signal Bool
33−isDown = Native.isDown
33+isDown = Native.Keyboard.isDown
3434
3535-- Whether the shift key is pressed.
3636shift : Signal Bool
37−shift = Native.isDown 16
37+shift = isDown 16
3838
3939-- Whether the control key is pressed.
4040ctrl : Signal Bool
41−ctrl = Native.isDown 17
41+ctrl = isDown 17
4242
4343-- Whether the space key is pressed.
4444space : Signal Bool
45−space = Native.isDown 32
45+space = isDown 32
4646
4747-- Whether the enter key is pressed.
4848enter : Signal Bool
49−enter = Native.isDown 13
49+enter = isDown 13
5050
5151-- List of keys that are currently down.
5252keysDown : Signal [KeyCode]
53−keysDown = Native.keysDown
53+keysDown = Native.Keyboard.keysDown
5454
5555-- The latest key that has been pressed.
5656lastPressed : Signal KeyCode
57−lastPressed = Native.lastPressed
57+lastPressed = Native.Keyboard.lastPressed
libraries/List.elm+27−27
@@ -2,33 +2,33 @@
22module List where
33
44import open Basics
5−import Native.List as Native
5+import Native.List
66
77-- Add an element to the front of a list `(1 :: [2,3] == [1,2,3])`
88(::) : a -> [a] -> [a]
9−(::) = Native.cons
9+(::) = Native.List.cons
1010
1111-- Puts two appendable things together:
1212--
1313-- [1,1] ++ [2,3] == [1,1,2,3]
1414-- "abc" ++ "123" == "abc123"
1515(++) : appendable -> appendable -> appendable
16−(++) = Native.append
16+(++) = Native.List.append
1717
1818-- Extract the first element of a list. List must be non-empty.
1919-- `(head [1,2,3] == 1)`
2020head : [a] -> a
21−head = Native.head
21+head = Native.List.head
2222
2323-- Extract the elements after the head of the list. List must be non-empty.
2424-- `(tail [1,2,3] == [2,3])`
2525tail : [a] -> [a]
26−tail = Native.tail
26+tail = Native.List.tail
2727
2828-- Extract the last element of a list. List must be non-empty.
2929-- `(last [1,2,3] == 3)`
3030last : [a] -> a
31−last = Native.last
31+last = Native.List.last
3232
3333-- Check if a list is empty `(isEmpty [] == True)`
3434isEmpty : [a] -> Bool
@@ -39,69 +39,69 @@ isEmpty xs =
3939
4040-- Apply a function to every element of a list: `(map sqrt [1,4,9] == [1,2,3])`
4141map : (a -> b) -> [a] -> [b]
42−map = Native.map
42+map = Native.List.map
4343
4444-- Reduce a list from the left: `(foldl (::) [] "gateman" == "nametag")`
4545foldl : (a -> b -> b) -> b -> [a] -> b
46−foldl = Native.foldl
46+foldl = Native.List.foldl
4747
4848-- Reduce a list from the right: `(foldr (+) 0 [1,2,3] == 6)`
4949foldr : (a -> b -> b) -> b -> [a] -> b
50−foldr = Native.foldr
50+foldr = Native.List.foldr
5151
5252-- Reduce a list from the left without a base case. List must be non-empty.
5353foldl1 : (a -> a -> a) -> [a] -> a
54−foldl1 = Native.foldl1
54+foldl1 = Native.List.foldl1
5555
5656-- Reduce a list from the right without a base case. List must be non-empty.
5757foldr1 : (a -> a -> a) -> [a] -> a
58−foldr1 = Native.foldr1
58+foldr1 = Native.List.foldr1
5959
6060-- Reduce a list from the left, building up all of the intermediate results into a list.
6161--
6262-- scanl (+) 0 [1,2,3,4] == [0,1,3,6,10]
6363scanl : (a -> b -> b) -> b -> [a] -> [b]
64−scanl = Native.scanl
64+scanl = Native.List.scanl
6565
6666-- Same as scanl but it doesn't require a base case. List must be non-empty.
6767--
6868-- scanl1 (+) [1,2,3,4] == [1,3,6,10]
6969scanl1 : (a -> a -> a) -> [a] -> [a]
70−scanl1 = Native.scanl1
70+scanl1 = Native.List.scanl1
7171
7272-- Filter out elements which do not satisfy the predicate: `(filter isLower "AaBbCc" == "abc")`
7373filter : (a -> Bool) -> [a] -> [a]
74−filter = Native.filter
74+filter = Native.List.filter
7575
7676-- Determine the length of a list: `(length "innumerable" == 11)`
7777length : [a] -> Int
78−length = Native.length
78+length = Native.List.length
7979
8080-- Reverse a list. `(reverse [1..4] == [4,3,2,1])`
8181reverse : [a] -> [a]
82−reverse = Native.reverse
82+reverse = Native.List.reverse
8383
8484-- Check to see if all elements satisfy the predicate.
8585all : (a -> Bool) -> [a] -> Bool
86−all = Native.all
86+all = Native.List.all
8787
8888-- Check to see if any elements satisfy the predicate.
8989any : (a -> Bool) -> [a] -> Bool
90−any = Native.any
90+any = Native.List.any
9191
9292-- Check to see if all elements are True.
9393and : [Bool] -> Bool
94−and = Native.and
94+and = Native.List.and
9595
9696-- Check to see if any elements are True.
9797or : [Bool] -> Bool
98−or = Native.or
98+or = Native.List.or
9999
100100-- Concatenate a list of appendable things:
101101--
102102-- concat ["tree","house"] == "treehouse"
103103concat : [appendable] -> appendable
104−concat = Native.concat
104+concat = Native.List.concat
105105
106106-- Map a given function onto a list and flatten the resulting lists.
107107--
@@ -139,14 +139,14 @@ partition pred lst =
139139-- zip [1,2,3] [6,7] == [(1,6),(2,7)]
140140-- zip == zipWith (,)
141141zip : [a] -> [b] -> [(a,b)]
142−zip = Native.zip
142+zip = Native.List.zip
143143
144144-- Combine two lists, combining them with the given function.
145145-- If one list is longer, the extra elements are dropped.
146146--
147147-- zipWith (+) [1,2,3] [1,2,3,4] == [2,4,6]
148148zipWith : (a -> b -> c) -> [a] -> [b] -> [c]
149−zipWith = Native.zipWith
149+zipWith = Native.List.zipWith
150150
151151-- Decompose a list of tuples.
152152unzip : [(a,b)] -> ([a],[b])
@@ -159,14 +159,14 @@ unzip pairs =
159159--
160160-- split "," "hello,there,friend" == ["hello", "there", "friend"]
161161split : [a] -> [a] -> [[a]]
162−split = Native.split
162+split = Native.List.split
163163
164164-- Places the given value between all of the lists in the second argument
165165-- and concatenates the result.
166166--
167167-- join "a" ["H","w","ii","n"] == "Hawaiian"
168168join : appendable -> [appendable] -> appendable
169−join = Native.join
169+join = Native.List.join
170170
171171-- Places the given value between all members of the given list.
172172--
@@ -180,8 +180,8 @@ intersperse sep xs =
180180
181181-- Take the first n members of a list: `(take 2 [1,2,3,4] == [1,2])`
182182take : Int -> [a] -> [a]
183−take = Native.take
183+take = Native.List.take
184184
185185-- Drop the first n members of a list: `(drop 2 [1,2,3,4] == [3,4])`
186186drop : Int -> [a] -> [a]
187−drop = Native.drop
187+drop = Native.List.drop
libraries/Matrix2D.elm+5−5
@@ -1,7 +1,7 @@
11
22module Matrix2D where
33
4−import Native.Matrix2D as Native
4+import Native.Matrix2D
55
66data Matrix2D = Matrix2D
77
@@ -10,7 +10,7 @@ data Matrix2D = Matrix2D
1010-- / 1 0 \\
1111-- \\ 0 1 /
1212identity : Matrix2D
13−identity = Native.identity
13+identity = Native.Matrix2D.identity
1414
1515-- Creates an arbitrary matrix. This lets you create scales, shears, reflections,
1616-- translations, or any other 2D transform.
@@ -22,7 +22,7 @@ identity = Native.identity
2222--
2323-- And `dx` and `dy` are the translation values.
2424matrix : Float -> Float -> Float -> Float -> Float -> Float -> Matrix2D
25−matrix = Native.matrix
25+matrix = Native.Matrix2D.matrix
2626
2727-- Creates a [rotation matrix](http://en.wikipedia.org/wiki/Rotation_matrix).
2828-- Given an angle t, it creates a counterclockwise rotation matrix:
@@ -30,7 +30,7 @@ matrix = Native.matrix
3030-- / cos t -sin t \\
3131-- \\ sin t cos t /
3232rotation : Float -> Matrix2D
33−rotation = Native.rotation
33+rotation = Native.Matrix2D.rotation
3434
3535-- Multiplies two matrices together:
3636--
@@ -39,4 +39,4 @@ rotation = Native.rotation
3939-- / a11 a12 \\ . / b11 b12 \\
4040-- \\ a21 a22 / \\ b21 b22 /
4141multiply : Matrix2D -> Matrix2D -> Matrix2D
42−multiply = Native.multiply
42+multiply = Native.Matrix2D.multiply
libraries/Mouse.elm+7−7
@@ -2,30 +2,30 @@
22module Mouse where
33
44import Signal (Signal)
5−import Native.Mouse as Native
5+import Native.Mouse
66
77-- The current mouse position.
88position : Signal (Int,Int)
9−position = Native.position
9+position = Native.Mouse.position
1010
1111-- The current x-coordinate of the mouse.
1212x : Signal Int
13−x = Native.x
13+x = Native.Mouse.x
1414
1515-- The current y-coordinate of the mouse.
1616y : Signal Int
17−y = Native.y
17+y = Native.Mouse.y
1818
1919-- The current state of the left mouse-button.
2020-- True when the button is down, and false otherwise.
2121isDown : Signal Bool
22−isDown = Native.isDown
22+isDown = Native.Mouse.isDown
2323
2424-- True immediately after the left mouse-button has been clicked,
2525-- and false otherwise.
2626isClicked : Signal Bool
27−isClicked = Native.isClicked
27+isClicked = Native.Mouse.isClicked
2828
2929-- Always equal to unit. Event triggers on every mouse click.
3030clicks : 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) {
33 'use strict';
44 if (elm.Native.Basics) return elm.Native.Basics;
55
6− var JS = Elm.JavaScript(elm);
7− var Maybe = Elm.Maybe(elm);
6+ var JS = Elm.Native.JavaScript(elm);
7+ // var Maybe = Elm.Maybe(elm);
88 var Utils = Elm.Native.Utils(elm);
9− var Char = Elm.Char(elm);
9+ //var Char = Elm.Char(elm);
1010
1111 function div(a,b) { return (a/b)|0; }
1212 function rem(a,b) { return a % b; }
@@ -26,7 +26,7 @@ Elm.Native.Basics = function(elm) {
2626 function uncurry(f,v) { return A2(f,v._0,v._1); }
2727 function fst(t) { return t._0; }
2828 function snd(t) { return t._1; }
29−
29+/*
3030 function readInt(str) {
3131 var s = JS.fromString(str);
3232 var len = s.length;
@@ -62,7 +62,7 @@ Elm.Native.Basics = function(elm) {
6262 }
6363 return Maybe.Just(parseFloat(s));
6464 }
65−
65+*/
6666 var basics = {
6767 div:F2(div),
6868 rem:F2(rem),
@@ -95,8 +95,8 @@ Elm.Native.Basics = function(elm) {
9595 round:Math.round,
9696 toFloat:function(x) { return x; },
9797
98− readInt:readInt,
99− readFloat:readFloat,
98+ //readInt:readInt,
99+ //readFloat:readFloat,
100100
101101 curry:F3(curry),
102102 uncurry:F2(uncurry),
libraries/Random.elm+3−3
@@ -2,15 +2,15 @@
22module Random where
33
44import Signal (Signal)
5−import Native.Random as Native
5+import Native.Random
66
77-- Given a range from low to high and a signal of values, this produces
88-- a new signal that changes whenever the input signal changes. The new
99-- values are random number between 'low' and 'high' inclusive.
1010range : Int -> Int -> Signal a -> Signal Int
11−range = Native.range
11+range = Native.Random.range
1212
1313-- Produces a new signal that changes whenever the input signal changes.
1414-- The new values are random numbers in [0..1).
1515float : Signal a -> Signal Float
16−float = Native.float
16+float = Native.Random.float
libraries/Signal.elm+24−24
@@ -7,7 +7,7 @@
77-- Note: There are lift functions up to `lift8`.
88module Signal where
99
10−import Native.Signal as Native
10+import Native.Signal
1111import List (foldr)
1212
1313data Signal a = Signal
@@ -16,37 +16,37 @@ data Signal a = Signal
1616
1717-- Create a constant signal that never changes.
1818constant : a -> Signal a
19−constant = Native.constant
19+constant = Native.Signal.constant
2020
2121-- Transform a signal with a given function.
2222lift : (a -> b) -> Signal a -> Signal b
23−lift = Native.lift
23+lift = Native.Signal.lift
2424
2525-- Combine two signals with a given function.
2626lift2 : (a -> b -> c) -> Signal a -> Signal b -> Signal c
27−lift2 = Native.lift2
27+lift2 = Native.Signal.lift2
2828
2929-- Combine three signals with a given function.
3030lift3 : (a -> b -> c -> d) -> Signal a -> Signal b -> Signal c -> Signal d
31−lift3 = Native.lift3
31+lift3 = Native.Signal.lift3
3232
3333lift4 : (a -> b -> c -> d -> e) -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e
34−lift4 = Native.lift4
34+lift4 = Native.Signal.lift4
3535
3636lift5 : (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
3838
3939lift6 : (a -> b -> c -> d -> e -> f -> g)
4040 -> Signal a -> Signal b -> Signal c -> Signal d -> Signal e -> Signal f -> Signal g
41−lift6 = Native.lift6
41+lift6 = Native.Signal.lift6
4242
4343lift7 : (a -> b -> c -> d -> e -> f -> g -> h)
4444 -> 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
4646
4747lift8 : (a -> b -> c -> d -> e -> f -> g -> h -> i)
4848 -> 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
5050
5151
5252-- Create a past-dependent signal. Each value given on the input signal will
@@ -54,21 +54,21 @@ lift8 = Native.lift8
5454--
5555-- For instance, `(foldp (\\t acc -> acc + 1) 0 (Time.every second))` increments every second.
5656foldp : (a -> b -> b) -> b -> Signal a -> Signal b
57−foldp = Native.foldp
57+foldp = Native.Signal.foldp
5858
5959-- Merge two signals into one, biased towards the first signal if both signals
6060-- update at the same time.
6161merge : Signal a -> Signal a -> Signal a
62−merge = Native.merge
62+merge = Native.Signal.merge
6363
6464-- Merge many signals into one, biased towards the left-most signal if multiple
6565-- signals update simultaneously.
6666merges : [Signal a] -> Signal a
67−merges = Native.merges
67+merges = Native.Signal.merges
6868
6969-- Combine a list of signals into a signal of lists.
7070combine : [Signal a] -> Signal [a]
71−combine = foldr (Native.lift2 (::)) (Native.constant [])
71+combine = foldr (Native.Signal.lift2 (::)) (Native.Signal.constant [])
7272
7373 -- Merge two signals into one, but distinguishing the values by marking the first
7474 -- signal as `Left` and the second signal as `Right`. This allows you to easily
@@ -77,23 +77,23 @@ combine = foldr (Native.lift2 (::)) (Native.constant [])
7777
7878-- Count the number of events that have occured.
7979count : Signal a -> Signal Int
80−count = Native.count
80+count = Native.Signal.count
8181
8282-- Count the number of events that have occured that satisfy a given predicate.
8383countIf : (a -> Bool) -> Signal a -> Signal Int
84−countIf = Native.countIf
84+countIf = Native.Signal.countIf
8585
8686-- Keep only events that satisfy the given predicate. Elm does not allow
8787-- undefined signals, so a base case must be provided in case the predicate is
8888-- never satisfied.
8989keepIf : (a -> Bool) -> a -> Signal a -> Signal a
90−keepIf = Native.keepIf
90+keepIf = Native.Signal.keepIf
9191
9292-- Drop events that satisfy the given predicate. Elm does not allow undefined
9393-- signals, so a base case must be provided in case the predicate is never
9494-- satisfied.
9595dropIf : (a -> Bool) -> a -> Signal a -> Signal a
96−dropIf = Native.dropIf
96+dropIf = Native.Signal.dropIf
9797
9898-- Keep events only when the first signal is true. When the first signal becomes
9999-- true, the most recent value of the second signal will be propagated. Until
@@ -101,7 +101,7 @@ dropIf = Native.dropIf
101101-- not allow undefined signals, so a base case must be provided in case the first
102102-- signal is never true.
103103keepWhen : Signal Bool -> a -> Signal a -> Signal a
104−keepWhen = Native.keepWhen
104+keepWhen = Native.Signal.keepWhen
105105
106106-- Drop events when the first signal is true. When the first signal becomes false,
107107-- the most recent value of the second signal will be propagated. Until the first
@@ -109,26 +109,26 @@ keepWhen = Native.keepWhen
109109-- undefined signals, so a base case must be provided in case the first signal is
110110-- always true.
111111dropWhen : Signal Bool -> a -> Signal a -> Signal a
112−dropWhen = Native.dropWhen
112+dropWhen = Native.Signal.dropWhen
113113
114114-- Drop sequential repeated values. For example, if a signal produces the
115115-- sequence `[1,1,2,2,1]`, it becomes `[1,2,1]` by dropping the values that
116116-- are the same as the previous value.
117117dropRepeats : Signal a -> Signal a
118−dropRepeats = Native.dropRepeats
118+dropRepeats = Native.Signal.dropRepeats
119119
120120-- Sample from the second input every time an event occurs on the first input.
121121-- For example, `(sampleOn clicks (every second))` will give the approximate
122122-- time of the latest click.
123123sampleOn : Signal a -> Signal b -> Signal b
124−sampleOn = Native.sampleOn
124+sampleOn = Native.Signal.sampleOn
125125
126126-- An alias for `lift`. A prettier way to apply a
127127-- function to the current value of a signal.
128128--
129129-- lift f signal == f <~ signal
130130(<~) : (a -> b) -> Signal a -> Signal b
131−(<~) = Native.lift
131+f <~ s = Native.Signal.lift f s
132132
133133-- Signal application. This takes two signals, holding a function and
134134-- a value. It applies the current function to the current value.
@@ -138,4 +138,4 @@ sampleOn = Native.sampleOn
138138-- scene <~ Window.dimensions ~ Mouse.position
139139-- lift2 scene Window.dimensions Mouse.position
140140(~) : 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)
66import Graphics.Element (Element, Three, Pos, ElementPrim, Properties)
77import Maybe (Maybe)
88import JavaScript (JSString)
9−import Native.Text as Native
9+import Native.Text
1010
1111data Text = Text
1212
1313-- Convert a string into text which can be styled and displayed.
1414toText : String -> Text
15−toText = Native.toText
15+toText = Native.Text.toText
1616
1717-- Set the typeface of some text. The first argument should be a comma separated listing of the desired typefaces
1818-- "helvetica, arial, sans-serif"
1919-- Works the same as the CSS font-family property.
2020typeface : String -> Text -> Text
21−typeface = Native.typeface
21+typeface = Native.Text.typeface
2222
2323-- Switch to a monospace typeface. Good for code snippets.
2424monospace : Text -> Text
25−monospace = Native.monospace
25+monospace = Native.Text.monospace
2626
2727-- Make text big and noticable.
2828header : Text -> Text
29−header = Native.header
29+header = Native.Text.header
3030
3131-- Create a link.
3232link : String -> Text -> Text
33−link = Native.link
33+link = Native.Text.link
3434
3535-- Set the height of text in pixels.
3636height : Float -> Text -> Text
37−height = Native.height
37+height = Native.Text.height
3838
3939-- Set the color of a string.
4040color : Color -> Text -> Text
41−color = Native.color
41+color = Native.Text.color
4242
4343-- Make a string bold.
4444bold : Text -> Text
45−bold = Native.bold
45+bold = Native.Text.bold
4646
4747-- Italicize a string.
4848italic : Text -> Text
49−italic = Native.italic
49+italic = Native.Text.italic
5050
5151-- Draw a line above a string.
5252overline : Text -> Text
53−overline = Native.overline
53+overline = Native.Text.overline
5454
5555-- Underline a string.
5656underline : Text -> Text
57−underline = Native.underline
57+underline = Native.Text.underline
5858
5959-- Draw a line through a string.
6060strikeThrough : Text -> Text
61−strikeThrough = Native.strikeThrough
61+strikeThrough = Native.Text.strikeThrough
6262
6363-- Display justified, styled text.
6464justified : Text -> Element
65−justified = Native.justified
65+justified = Native.Text.justified
6666
6767-- Display centered, styled text.
6868centered : Text -> Element
69−centered = Native.centered
69+centered = Native.Text.centered
7070
7171-- Display right justified, styled text.
7272righted : Text -> Element
73−righted = Native.righted
73+righted = Native.Text.righted
7474
7575-- Display styled text.
7676text : Text -> Element
77−text = Native.text
77+text = Native.Text.text
7878
7979-- Display a plain string.
8080plainText : String -> Element
81−plainText = Native.plainText
81+plainText = Native.Text.plainText
8282
8383-- Convert anything to it's textual representation and make it displayable in browser
8484--
@@ -86,4 +86,4 @@ plainText = Native.plainText
8686--
8787-- Excellent for debugging.
8888asText : a -> Element
89−asText = Native.asText
89+asText = Native.Text.asText
libraries/Time.elm+7−7
@@ -2,7 +2,7 @@
22module Time where
33
44import open Basics
5−import Native.Time as Native
5+import Native.Time
66import Signal (Signal)
77
88-- Type alias to make it clearer when you are working with time values.
@@ -41,7 +41,7 @@ inHours t = t / hour
4141-- the desired FPS. A time delta is the time between the last frame and the
4242-- current frame.
4343fps : number -> Signal Time
44−fps = Native.fps
44+fps = Native.Time.fps
4545
4646-- Same as the fps function, but you can turn it on and off. Allows you
4747-- to do brief animations based on user input without major inefficiencies.
@@ -49,12 +49,12 @@ fps = Native.fps
4949-- the pause was. This way summing the deltas will actually give the amount
5050-- of time that the output signal has been running.
5151fpsWhen : number -> Signal Bool -> Signal Time
52−fpsWhen = Native.fpsWhen
52+fpsWhen = Native.Time.fpsWhen
5353
5454-- Takes a time interval t. The resulting signal is the current time,
5555-- updated every t.
5656every : Time -> Signal Time
57−every = Native.every
57+every = Native.Time.every
5858
5959-- Takes a time `t` and any signal. The resulting boolean signal
6060-- is true for time `t` after every event on the input signal.
@@ -62,16 +62,16 @@ every = Native.every
6262-- that is true for one second after each mouse click and false
6363-- otherwise.
6464since : Time -> Signal a -> Signal Bool
65−since = Native.since
65+since = Native.Time.since
6666
6767-- Add a timestamp to any signal. Timestamps increase monotonically. Each
6868-- timestamp is related to a specfic event, so `Mouse.x` and `Mouse.y` will
6969-- always have the same timestamp because they both rely on the same
7070-- underlying event.
7171timestamp : Signal a -> Signal (Time, a)
72−timestamp = Native.timestamp
72+timestamp = Native.Time.timestamp
7373
7474-- Delay a signal by a certain amount of time. So `(delay second Mouse.clicks)`
7575-- will update one second later than any mouse click.
7676delay : Time -> Signal a -> Signal a
77−delay = Native.delay
77+delay = Native.Time.delay
libraries/Touch.elm+3−3
@@ -3,7 +3,7 @@
33module Touch where
44
55import Signal (Signal)
6−import Native.Touch as Native
6+import Native.Touch
77import Time (Time)
88
99-- 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 }
1616
1717-- A list of ongoing touches.
1818touches : Signal [Touch]
19−touches = Native.touches
19+touches = Native.Touch.touches
2020
2121-- The last position that was tapped. Default value is `{x=0,y=0}`.
2222-- Updates whenever the user taps the screen.
2323taps : 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
44
55import Signal (Signal)
66import Basics (String)
7−import Native.WebSocket as Native
7+import Native.WebSocket
88
99-- Create a web-socket. The first argument is the URL of the desired
1010-- web-socket server. The input signal holds the outgoing messages,
1111-- and the resulting signal contains the incoming ones.
1212connect : String -> Signal String -> Signal String
13−connect = Native.connect
13+connect = Native.WebSocket.connect
1414
1515-- data Action = Open String | Close String | Send String String
1616-- connections : Signal Action -> Signal String
libraries/Window.elm+4−4
@@ -2,17 +2,17 @@
22module Window where
33
44import Signal (Signal)
5−import Native.Window as Native
5+import Native.Window
66
77-- The current dimensions of the window (i.e. the area viewable to the
88-- user, not including scroll bars).
99dimensions : Signal (Int,Int)
10−dimensions = Native.dimensions
10+dimensions = Native.Window.dimensions
1111
1212-- The current width of the window.
1313width : Signal Int
14−width = Native.width
14+width = Native.Window.width
1515
1616-- The current height of the window.
1717height : Signal Int
18−height = Native.height
18+height = Native.Window.height