Elm 0.8.0.1 → 0.8.0.2
raw patch · 6 files changed
+589/−209 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Elm.cabal +2/−4
- compiler/Docs.hs +20/−9
- compiler/Parse/Foreign.hs +7/−8
- compiler/Parse/Types.hs +16/−13
- docs.json +317/−1
- elm-runtime.js +227/−174
Elm.cabal view
@@ -1,5 +1,5 @@ Name: Elm-Version: 0.8.0.1+Version: 0.8.0.2 Synopsis: The Elm language module. Description: Elm aims to make client-side web-development more pleasant. It is a statically/strongly typed, functional reactive@@ -71,14 +71,13 @@ blaze-html == 0.5.* || == 0.6.*, blaze-markup == 0.5.1.*, text,- template-haskell, shakespeare >= 1,+ template-haskell, pandoc >= 1.10, bytestring, hjsmin, indents, filepath,- template-haskell, json, directory @@ -131,7 +130,6 @@ hjsmin, indents, filepath,- template-haskell, json, directory
compiler/Docs.hs view
@@ -5,6 +5,8 @@ import Control.Applicative ((<$>), (<*>)) import Data.List (intercalate) import Data.Maybe (catMaybes)+import Types.Types ((==>), Type ( ADT, VarT ) )+import Parse.Types (datatype) import Parse.Library import Parse.Modules (moduleDef) import Text.Parsec hiding (newline,spaces)@@ -35,15 +37,19 @@ docParse = setupParser $ do optional freshLine (names, exports) <- option (["Main"],[]) moduleDef- info <- many (annotation exports <|> try skip <|> end)- return (intercalate "." names, catMaybes info)+ info <- many (try (annotation exports) <|> try skip <|> end)+ return (intercalate "." names, concat info) where- skip = manyTill anyChar simpleNewline >> return Nothing- end = many1 anyChar >> return Nothing+ skip = manyTill anyChar simpleNewline >> return []+ end = many1 anyChar >> return [] -annotation :: [String] -> IParser (Maybe (String, String, String))+annotation :: [String] -> IParser [(String, String, String)] annotation exports =- try ((\c n t -> export (n,t,c)) <$> comment <*> (try adt <|> name) <*> tipe)+ do description <- comment+ extras <- option [] (lookAhead adt)+ varName <- try typeDef <|> name+ varType <- tipe+ return $ extras ++ export varName varType description where comment = concatMap clip <$> many lineComment clip str = case str of { ' ':rest -> rest ; _ -> str } ++ "\n"@@ -53,11 +59,16 @@ tipe = manyTill anyChar (try (simpleNewline >> notFollowedBy (string " "))) - export info@(name,_,_) =- if null exports || name `elem` exports then Just info else Nothing+ export name tipe desc =+ if null exports || name `elem` exports then [(name,tipe,desc)] else [] - adt = lookAhead ((string "data" <|> string "type") >> whitespace >> capVar)+ typeDef = lookAhead ((string "data" <|> string "type") >> whitespace >> capVar) + adt = do+ (Datatype name tvs constructors) <- datatype+ let toType (cName, typeArgs) =+ (cName, show $ foldr (==>) (ADT name $ map VarT tvs) typeArgs, "")+ return $ map toType constructors setupParser p source = case iParse p "" source of
compiler/Parse/Foreign.hs view
@@ -11,23 +11,22 @@ import Parse.Types import Types.Types (signalOf) - foreignDef = do try (reserved "foreign") ; whitespace importEvent <|> exportEvent exportEvent = do- try (reserved "export" >> whitespace >> reserved "jsevent" >> whitespace)+ try (reserved "export") >> whitespace >> reserved "jsevent" >> whitespace js <- jsVar ; whitespace elm <- lowVar ; whitespace hasType ; whitespace tipe <- typeExpr case tipe of ADTPT "Signal" [pt] ->- either fail (return . ExportEvent js elm . signalOf) (toForeignType pt)- _ -> fail "When exporting events, the exported value must be a Signal."+ either error (return . ExportEvent js elm . signalOf) (toForeignType pt)+ _ -> error "When exporting events, the exported value must be a Signal." importEvent = do- try (reserved "import" >> whitespace >> reserved "jsevent" >> whitespace)+ try (reserved "import") >> whitespace >> reserved "jsevent" >> whitespace js <- jsVar ; whitespace base <- term <?> "Base case for imported signal (signals cannot be undefined)" whitespace@@ -36,15 +35,15 @@ tipe <- typeExpr case tipe of ADTPT "Signal" [pt] ->- either fail (return . ImportEvent js base elm . signalOf) (toForeignType pt)- _ -> fail "When importing events, the imported value must be a Signal."+ either error (return . ImportEvent js base elm . signalOf) (toForeignType pt)+ _ -> error "When importing events, the imported value must be a Signal." jsVar :: (Monad m) => ParsecT [Char] u m String jsVar = betwixt '"' '"' $ do v <- (:) <$> (letter <|> char '_') <*> many (alphaNum <|> char '_') if v `notElem` jsReserveds then return v else- fail $ "'" ++ v +++ error $ "'" ++ v ++ "' is not a good name for a importing or exporting JS values." jsReserveds =
compiler/Parse/Types.hs view
@@ -5,7 +5,7 @@ import Control.Monad (liftM,mapM) import Data.Char (isUpper,isLower) import Data.Maybe (fromMaybe)-import Data.List (lookup)+import Data.List (lookup,intercalate) import Text.Parsec import Text.Parsec.Indent @@ -18,6 +18,7 @@ | LambdaPT ParseType ParseType | ADTPT String [ParseType] | RecordPT (Maybe ParseType) [(String,ParseType)]+ deriving (Show) listPT t = ADTPT "List" [t] tuplePT ts = ADTPT ("Tuple" ++ show (length ts)) ts@@ -150,18 +151,20 @@ toForeignType (LambdaPT t1 t2) = fail $ "Elm's JavaScript event interface does not yet handle functions. " ++ "Only simple values can be imported and exported in this release."- --LambdaT <$> toForeignType t1 <*> toForeignType t2-toForeignType (ADTPT name args)- | isJsStructure name = ADT name <$> mapM toForeignType args- | otherwise =- Left $ "'" ++ name ++ "' is not an exportable type " ++- "constructor. Only 'JSArray' and 'JSTupleN' are exportable." +toForeignType (ADTPT "JSArray" args) =+ ADT "JSArray" <$> mapM toForeignType args++toForeignType (ADTPT name _) =+ Left $ "'" ++ name ++ "' is not an exportable type " +++ "constructor. Only 'JSArray' is exportable."+ toForeignType (VarPT x@(c:_))+ | x `elem` jsTypes = Right (ADT x []) | isLower c =- Left "All exported types must be concrete types (JSNumber, JSString, etc.)"- | x `elem` ["JSString","JSNumber","JSElement","JSBool"] = Right (ADT x [])- | otherwise = Left $ "'" ++ x ++ "' is not an exportable type. Only JSTypes are exportable."--isJsStructure name = name == "JSArray" || isTuple- where isTuple = "JSTuple" == take 7 name && drop 7 name `elem` map show [2..5]+ Left $ "All exported types must be concrete types." ++ msg+ | otherwise =+ Left $ "'" ++ x ++ "' is not an exportable type." ++ msg+ where+ msg = " The following types are exportable: " ++ intercalate ", " jsTypes+ jsTypes = ["JSString","JSNumber","JSDomNode","JSBool","JSObject"]
docs.json view
@@ -485,6 +485,18 @@ "type" : "Comparable a -> Comparable a -> Order", "desc" : "Compare any two comparable values. Comparable values include `String`, `Char`,\n`Int`, `Float`, `Time`, or a list or tuple containing comparable values.\nThese are also the only values that work as `Dict` keys or `Set` members.\n" }, + { "name" : "LT", + "type" : "Order", + "desc" : "" + }, + { "name" : "EQ", + "type" : "Order", + "desc" : "" + }, + { "name" : "GT", + "type" : "Order", + "desc" : "" + }, { "name" : "Order", "type" : "data Order = LT | EQ | GT", "desc" : "Represents the relative ordering of two things.\nThe relations are less than, equal to, and greater than.\n" @@ -609,6 +621,14 @@ }, { "name" : "Maybe", "values" : [ + { "name" : "Just", + "type" : "t1 -> Maybe t1", + "desc" : "" + }, + { "name" : "Nothing", + "type" : "Maybe t1", + "desc" : "" + }, { "name" : "Maybe", "type" : "data Maybe a = Just a | Nothing", "desc" : "The Maybe datatype. Useful when a computation may or may not\nresult in a value (e.g. logarithm is defined only for positive numbers).\n" @@ -845,6 +865,30 @@ }, { "name" : "Json", "values" : [ + { "name" : "String", + "type" : "String -> JsonValue", + "desc" : "" + }, + { "name" : "Number", + "type" : "Float -> JsonValue", + "desc" : "" + }, + { "name" : "Boolean", + "type" : "Bool -> JsonValue", + "desc" : "" + }, + { "name" : "Null", + "type" : "JsonValue", + "desc" : "" + }, + { "name" : "Array", + "type" : "[JsonValue] -> JsonValue", + "desc" : "" + }, + { "name" : "Object", + "type" : "Dict String JsonValue -> JsonValue", + "desc" : "" + }, { "name" : "JsonValue", "type" : "data JsonValue\n = String String\n | Number Float\n | Boolean Bool\n | Null\n | Array [JsonValue]\n | Object (Dict String JsonValue)", "desc" : "This datatype can represent all valid values that can be held in a JSON\nobject. In Elm, a proper JSON object is represented as a (Dict String JsonValue)\nwhich is a mapping from strings to Json Values.\n" @@ -929,6 +973,18 @@ }, { "name" : "Http", "values" : [ + { "name" : "Success", + "type" : "t1 -> Response t1", + "desc" : "" + }, + { "name" : "Waiting", + "type" : "Response t1", + "desc" : "" + }, + { "name" : "Failure", + "type" : "Int -> String -> Response t1", + "desc" : "" + }, { "name" : "Response", "type" : "data Response a = Success a | Waiting | Failure Int String", "desc" : "The datatype for responses. Success contains only the returned message.\nFailures contain both an error code and an error message.\n" @@ -961,9 +1017,17 @@ }, { "name" : "Either", "values" : [ + { "name" : "Left", + "type" : "t1 -> Either t1 t2", + "desc" : "" + }, + { "name" : "Right", + "type" : "t2 -> Either t1 t2", + "desc" : "" + }, { "name" : "Either", "type" : "data Either a b = Left a | Right b", - "desc" : "Represents any data that can take two different types.\n\nThis can also be used for error handling `(Either String a)` where error\nmessages are stored on the left, and the correct values (“right” values) are stored on the right.\n" + "desc" : "Represents any data that can take two different types.\n\nThis can also be used for error handling `(Either String a)` where error\nmessages are stored on the left, and the correct values (“right”\nvalues) are stored on the right.\n" }, { "name" : "either", "type" : "(a -> c) -> (b -> c) -> Either a b -> c", @@ -993,6 +1057,22 @@ }, { "name" : "Dict", "values" : [ + { "name" : "Red", + "type" : "NColor", + "desc" : "" + }, + { "name" : "Black", + "type" : "NColor", + "desc" : "" + }, + { "name" : "RBNode", + "type" : "NColor -> t1 -> t2 -> Dict t1 t2 -> Dict t1 t2 -> Dict t1 t2", + "desc" : "" + }, + { "name" : "RBEmpty", + "type" : "Dict t1 t2", + "desc" : "" + }, { "name" : "empty", "type" : "Dict (Comparable k) v", "desc" : "Create an empty dictionary.\n" @@ -1065,10 +1145,86 @@ }, { "name" : "Date", "values" : [ + { "name" : "Mon", + "type" : "Day", + "desc" : "" + }, + { "name" : "Tue", + "type" : "Day", + "desc" : "" + }, + { "name" : "Wed", + "type" : "Day", + "desc" : "" + }, + { "name" : "Thu", + "type" : "Day", + "desc" : "" + }, + { "name" : "Fri", + "type" : "Day", + "desc" : "" + }, + { "name" : "Sat", + "type" : "Day", + "desc" : "" + }, + { "name" : "Sun", + "type" : "Day", + "desc" : "" + }, { "name" : "Day", "type" : "data Day = Mon | Tue | Wed | Thu | Fri | Sat | Sun", "desc" : "Represents the days of the week.\n" }, + { "name" : "Jan", + "type" : "Month", + "desc" : "" + }, + { "name" : "Feb", + "type" : "Month", + "desc" : "" + }, + { "name" : "Mar", + "type" : "Month", + "desc" : "" + }, + { "name" : "Apr", + "type" : "Month", + "desc" : "" + }, + { "name" : "May", + "type" : "Month", + "desc" : "" + }, + { "name" : "Jun", + "type" : "Month", + "desc" : "" + }, + { "name" : "Jul", + "type" : "Month", + "desc" : "" + }, + { "name" : "Aug", + "type" : "Month", + "desc" : "" + }, + { "name" : "Sep", + "type" : "Month", + "desc" : "" + }, + { "name" : "Oct", + "type" : "Month", + "desc" : "" + }, + { "name" : "Nov", + "type" : "Month", + "desc" : "" + }, + { "name" : "Dec", + "type" : "Month", + "desc" : "" + }, { "name" : "Month", "type" : "data Month = Jan | Feb | Mar | Apr\n | May | Jun | Jul | Aug\n | Sep | Oct | Nov | Dec", "desc" : "Represents the month of the year.\n" @@ -1114,6 +1270,10 @@ { "name" : "Color", "values" : [ { "name" : "Color", + "type" : "Int -> Int -> Int -> Float -> Color", + "desc" : "" + }, + { "name" : "Color", "type" : "data Color = Color Int Int Int Float", "desc" : "" }, @@ -1205,6 +1365,14 @@ "type" : "Float -> Float -> Float -> Color", "desc" : "Create [HSV colors](http://en.wikipedia.org/wiki/HSL_and_HSV).\nThis is very convenient for creating colors that cycle and shift.\n\n hsv (degrees 240) 1 1 == blue\n" }, + { "name" : "Linear", + "type" : "(Float,Float) -> (Float,Float) -> [(Float,Color)] -> Gradient", + "desc" : "" + }, + { "name" : "Radial", + "type" : "(Float,Float) -> Float -> (Float,Float) -> Float -> [(Float,Color)] -> Gradient", + "desc" : "" + }, { "name" : "Gradient", "type" : "data Gradient\n = Linear (Float,Float) (Float,Float) [(Float,Color)]\n | Radial (Float,Float) Float (Float,Float) Float [(Float,Color)]", "desc" : "" @@ -1269,6 +1437,10 @@ }, { "name" : "Automaton", "values" : [ + { "name" : "Step", + "type" : "(t1 -> (Automaton t1 t2,t2)) -> Automaton t1 t2", + "desc" : "" + }, { "name" : "Automaton", "type" : "data Automaton a b = Step (a -> (Automaton a b, b))", "desc" : "" @@ -1380,6 +1552,14 @@ { "name" : "email", "type" : "String -> (Signal Element, Signal String)", "desc" : "Same as `field` but it adds an annotation that this field is for email\naddresses. This is helpful for auto-complete and for mobile users who may\nget a custom keyboard with an `@` and `.com` button.\n" + }, + { "name" : "dropDown", + "type" : "[(String,a)] -> (Signal Element, Signal a)", + "desc" : "Create a drop-down menu. When the user selects a string,\nthe current state of the drop-down is set to the associated\nvalue. This lets you avoid manually mapping the string onto\nfunctions and values.\n" + }, + { "name" : "stringDropDown", + "type" : "[String] -> (Signal Element, Signal String)", + "desc" : "Create a drop-down menu for selecting strings. The resulting\nsignal of strings represents the string that is currently selected.\n" } ] }, @@ -1421,6 +1601,42 @@ "type" : "String -> Element -> Element", "desc" : "Create an `Element` that is a hyper-link.\n" }, + { "name" : "Image", + "type" : "ImageStyle -> Int -> Int -> JSString -> ElementPrim", + "desc" : "" + }, + { "name" : "Container", + "type" : "Position -> Element -> ElementPrim", + "desc" : "" + }, + { "name" : "Flow", + "type" : "Direction -> [Element] -> ElementPrim", + "desc" : "" + }, + { "name" : "Spacer", + "type" : "ElementPrim", + "desc" : "" + }, + { "name" : "RawHtml", + "type" : "JSString -> ElementPrim", + "desc" : "" + }, + { "name" : "Custom", + "type" : "ElementPrim", + "desc" : "" + }, + { "name" : "Plain", + "type" : "ImageStyle", + "desc" : "" + }, + { "name" : "Fitted", + "type" : "ImageStyle", + "desc" : "" + }, + { "name" : "Cropped", + "type" : "(Int,Int) -> ImageStyle", + "desc" : "" + }, { "name" : "image", "type" : "Int -> Int -> String -> Element", "desc" : "Create an image given a width, height, and image source.\n" @@ -1433,6 +1649,26 @@ "type" : "Int -> Int -> (Int,Int) -> String -> Element", "desc" : "Create a cropped image. Take a rectangle out of the picture starting\nat the given top left coordinate. If you have a 140-by-140 image,\nthe following will cut a 100-by-100 square out of the middle of it.\n\n croppedImage 100 100 (20,20) \"yogi.jpg\"\n" }, + { "name" : "P", + "type" : "Three", + "desc" : "" + }, + { "name" : "Z", + "type" : "Three", + "desc" : "" + }, + { "name" : "N", + "type" : "Three", + "desc" : "" + }, + { "name" : "Absolute", + "type" : "Int -> Pos", + "desc" : "" + }, + { "name" : "Relative", + "type" : "Float -> Pos", + "desc" : "" + }, { "name" : "container", "type" : "Int -> Int -> Position -> Element -> Element", "desc" : "Put an element in a container. This lets you position the element really\neasily, and there are tons of ways to set the `Position`.\nTo center `element` exactly in a 300-by-300 square you would say:\n\n container 300 300 middle element\n\nBy setting the color of the container, you can create borders.\n" @@ -1441,6 +1677,30 @@ "type" : "Int -> Int -> Element", "desc" : "Create an empty box. This is useful for getting your spacing right and\nfor making borders.\n" }, + { "name" : "DUp", + "type" : "Direction", + "desc" : "" + }, + { "name" : "DDown", + "type" : "Direction", + "desc" : "" + }, + { "name" : "DLeft", + "type" : "Direction", + "desc" : "" + }, + { "name" : "DRight", + "type" : "Direction", + "desc" : "" + }, + { "name" : "DIn", + "type" : "Direction", + "desc" : "" + }, + { "name" : "DOut", + "type" : "Direction", + "desc" : "" + }, { "name" : "flow", "type" : "Direction -> [Element] -> Element", "desc" : "Have a list of elements flow in a particular direction.\nThe `Direction` starts from the first element in the list.\n\n flow right [a,b,c]\n\n +---+---+---+\n | a | b | c |\n +---+---+---+\n" @@ -1573,14 +1833,50 @@ "type" : "type Form = {\n theta : Float,\n scale : Float,\n x : Float,\n y : Float,\n form : BasicForm\n }", "desc" : "" }, + { "name" : "Solid", + "type" : "Color -> FillStyle", + "desc" : "" + }, + { "name" : "Texture", + "type" : "String -> FillStyle", + "desc" : "" + }, + { "name" : "Gradient", + "type" : "Gradient -> FillStyle", + "desc" : "" + }, { "name" : "FillStyle", "type" : "data FillStyle\n = Solid Color\n | Texture String\n | Gradient Gradient", "desc" : "" }, + { "name" : "Flat", + "type" : "LineCap", + "desc" : "" + }, + { "name" : "Round", + "type" : "LineCap", + "desc" : "" + }, + { "name" : "Padded", + "type" : "LineCap", + "desc" : "" + }, { "name" : "LineCap", "type" : "data LineCap = Flat | Round | Padded", "desc" : "The shape of the ends of a line. \n" }, + { "name" : "Smooth", + "type" : "LineJoin", + "desc" : "" + }, + { "name" : "Sharp", + "type" : "Float -> LineJoin", + "desc" : "" + }, + { "name" : "Clipped", + "type" : "LineJoin", + "desc" : "" + }, { "name" : "LineJoin", "type" : "data LineJoin = Smooth | Sharp Float | Clipped", "desc" : "The shape of the “joints” of a line, where each line segment\nmeets. `Sharp` takes an argument to limit the length of the joint. This\ndefaults to 10.\n" @@ -1604,6 +1900,26 @@ { "name" : "dotted", "type" : "Color -> LineStyle", "desc" : "Create a dotted line style with a given color. Dashing equals `[3,3]`.\n" + }, + { "name" : "FPath", + "type" : "LineStyle -> Path -> BasicForm", + "desc" : "" + }, + { "name" : "FShape", + "type" : "Either LineStyle FillStyle -> Shape -> BasicForm", + "desc" : "" + }, + { "name" : "FImage", + "type" : "Int -> Int -> (Int,Int) -> String -> BasicForm", + "desc" : "" + }, + { "name" : "FElement", + "type" : "Element -> BasicForm", + "desc" : "" + }, + { "name" : "FGroup", + "type" : "Matrix2D -> [Form] -> BasicForm", + "desc" : "" }, { "name" : "BasicForm", "type" : "data BasicForm\n = FPath LineStyle Path\n | FShape (Either LineStyle FillStyle) Shape\n | FImage Int Int (Int,Int) String\n | FElement Element\n | FGroup Matrix2D [Form]",
elm-runtime.js view
@@ -978,7 +978,7 @@ case 'Object' : var obj = {}; var array = JS.fromList(Dict.toList(v._0)); - for (var i = arr.length; i--; ) { + for (var i = array.length; i--; ) { obj[JS.fromString(array[i]._0)] = fromValue(array[i]._1); } return obj; @@ -2092,7 +2092,7 @@ function registerReq(queue,responses) { return function(req) { - if (req.url !== "") { sendReq(queue,responses,req); } + if (req.url.ctor !== 'Nil') { sendReq(queue,responses,req); } }; } @@ -2119,7 +2119,7 @@ if (window.XMLHttpRequest) { request = new XMLHttpRequest(); } request.onreadystatechange = function(e) { if (request.readyState === 4) { - response.value = (request.status === 200 ? + response.value = (request.status >= 200 && request.status < 300 ? { ctor:'Success', _0:JS.toString(request.responseText) } : { ctor:'Failure', _0:request.status, _1:JS.toString(request.statusText) }); setTimeout(function() { updateQueue(queue,responses); }, 0); @@ -2149,13 +2149,51 @@ if (elm.Native.Graphics.Input) return elm.Native.Graphics.Input; var Render = ElmRuntime.use(ElmRuntime.Render.Element); - var Utils = ElmRuntime.use(ElmRuntime.Render.Utils); - var newNode = Utils.newElement, fromString = Utils.fromString, - toString = Utils.toString; + var newNode = ElmRuntime.use(ElmRuntime.Render.Utils).newElement; var Signal = Elm.Signal(elm); var newElement = Elm.Graphics.Element(elm).newElement; + var JS = Elm.Native.JavaScript(elm); + var Tuple2 = Elm.Native.Utils(elm).Tuple2; + function dropDown(values) { + var entries = JS.fromList(values); + var events = Signal.constant(entries[0]._1); + + var drop = newNode('select'); + drop.style.border = '0 solid'; + for (var i = 0; i < entries.length; ++i) { + var option = newNode('option'); + var name = JS.fromString(entries[i]._0); + option.value = name; + option.innerHTML = name; + drop.appendChild(option); + } + drop.addEventListener('change', function() { + elm.notify(events.id, entries[drop.selectedIndex]._1); + }); + + var t = drop.cloneNode(true); + t.style.visibility = "hidden"; + + elm.node.appendChild(t); + var style = window.getComputedStyle(t, null); + var w = Math.ceil(style.getPropertyValue("width").slice(0,-2) - 0); + var h = Math.ceil(style.getPropertyValue("height").slice(0,-2) - 0); + elm.node.removeChild(t); + + console.log(w,h); + var element = A3(newElement, w, h, { + ctor: 'Custom', + type: 'DropDown', + render: function render(model) { return drop; }, + update: function update(node, oldModel, newModel) {}, + model: {} + }); + + return Tuple2(Signal.constant(element), events); + } + function buttons(defaultValue) { var events = Signal.constant(defaultValue); @@ -2181,7 +2219,7 @@ type: 'Button', render: render, update: update, - model: { event:evnt, text:fromString(txt) } + model: { event:evnt, text:JS.fromString(txt) } }); } @@ -2301,8 +2339,8 @@ field.id = 'test'; field.type = type; - field.placeholder = fromString(model.placeHolder); - field.value = fromString(model.state.string); + field.placeholder = JS.fromString(model.placeHolder); + field.value = JS.fromString(model.state.string); setRange(field, model.state.selectionStart, model.state.selectionEnd, 'forward'); field.style.border = 'none'; state = model.state; @@ -2315,7 +2353,7 @@ end = field.selectionStart; } state = { _:{}, - string:toString(field.value), + string:JS.toString(field.value), selectionStart:start, selectionEnd:end }; elm.notify(events.id, field.elmHandler(state)); @@ -2337,7 +2375,7 @@ function update(node, oldModel, newModel) { node.elmHandler = newModel.handler; if (state === newModel.state) return; - var newStr = fromString(newModel.state.string); + var newStr = JS.fromString(newModel.state.string); if (node.value !== newStr) node.value = newStr; var start = newModel.state.selectionStart; @@ -2378,7 +2416,8 @@ checkboxes:checkboxes, fields:mkTextPool('text'), emails:mkTextPool('email'), - passwords:mkTextPool('password') + passwords:mkTextPool('password'), + dropDown:dropDown }; }; @@ -2849,7 +2888,7 @@ return f_11(e_13._0); case 'Right': return g_12(e_13._0); - }_E.Case('Line 15, Column 16') }();}); + }_E.Case('Line 16, Column 16') }();}); var isLeft_3 = function(e_16){ return function(){ switch (e_16.ctor) { @@ -2877,7 +2916,7 @@ return _L.Cons(e_21._0,vs_22); case 'Right': return vs_22; - }_E.Case('Line 39, Column 5') }();}); + }_E.Case('Line 40, Column 5') }();}); var consRight_9 = F2(function(e_24, vs_25){ return function(){ switch (e_24.ctor) { @@ -2885,19 +2924,19 @@ return vs_25; case 'Right': return _L.Cons(e_24._0,vs_25); - }_E.Case('Line 44, Column 5') }();}); - var consEither_10 = F2(function(e_27, _51000_28){ + }_E.Case('Line 45, Column 5') }();}); + var consEither_10 = F2(function(e_27, _52000_28){ return function(){ - switch (_51000_28.ctor) { + switch (_52000_28.ctor) { case 'Tuple2': return function(){ switch (e_27.ctor) { case 'Left': - return {ctor:"Tuple2", _0:_L.Cons(e_27._0,_51000_28._0), _1:_51000_28._1}; + return {ctor:"Tuple2", _0:_L.Cons(e_27._0,_52000_28._0), _1:_52000_28._1}; case 'Right': - return {ctor:"Tuple2", _0:_51000_28._0, _1:_L.Cons(e_27._0,_51000_28._1)}; - }_E.Case('Line 49, Column 5') }(); - }_E.Case('Line 49, Column 5') }();}); + return {ctor:"Tuple2", _0:_52000_28._0, _1:_L.Cons(e_27._0,_52000_28._1)}; + }_E.Case('Line 50, Column 5') }(); + }_E.Case('Line 50, Column 5') }();}); elm.Native = elm.Native||{}; var _ = elm.Native.Either||{}; _.$op = {}; @@ -3488,150 +3527,153 @@ Elm.Automaton = function(elm){ var N = Elm.Native, _N = N.Utils(elm), _L = N.List(elm), _E = N.Error(elm), _str = N.JavaScript(elm).toString; var $op = {}; + var _ = Elm.Signal(elm); var Signal = _; + var lift = _.lift, foldp = _.foldp; var Step_0 = function(a1){ return {ctor:"Step", _0:a1};}; - var run_1 = F3(function(_14000_12, base_13, inputs_14){ - return function(){ - switch (_14000_12.ctor) { - case 'Step': - return function(){ - var step_16 = F2(function(a_17, _13000_18){ - return function(){ - switch (_13000_18.ctor) { - case 'Tuple2': - switch (_13000_18._0.ctor) { - case 'Step': - return _13000_18._0._0(a_17); - }break; - }_E.Case('Line 13, Column 28') }();}); - return A2(lift, snd, A3(foldp, step_16, base_13, inputs_14));}(); - }_E.Case('Line 13, Column 3') }();}); - var step_2 = F2(function(a_20, _18000_21){ + var run_1 = F3(function(auto_12, base_13, inputs_14){ + return function(){ + var step_15 = F2(function(a_16, _15000_17){ + return function(){ + switch (_15000_17.ctor) { + case 'Tuple2': + switch (_15000_17._0.ctor) { + case 'Step': + return _15000_17._0._0(a_16); + }break; + }_E.Case('Line 15, Column 28') }();}); + return A2(lift, function(_0_19){ + return function(){ + switch (_0_19.ctor) { + case 'Tuple2': + return _0_19._1; + }_E.Case('Line 16, Column 23') }();}, A3(foldp, step_15, {ctor:"Tuple2", _0:auto_12, _1:base_13}, inputs_14));}();}); + var step_2 = F2(function(a_22, _20000_23){ return function(){ - switch (_18000_21.ctor) { + switch (_20000_23.ctor) { case 'Step': - return _18000_21._0(a_20); - }_E.Case('Line 18, Column 19') }();}); - $op['>>>'] = F2(function(f_23, g_24){ - return Step_0(function(a_25){ + return _20000_23._0(a_22); + }_E.Case('Line 20, Column 19') }();}); + $op['>>>'] = F2(function(f_25, g_26){ + return Step_0(function(a_27){ return function(){ - var _23000_26 = A2(step_2, a_25, f_23); - var f$_27 = function(){ - switch (_23000_26.ctor) { + var _25000_28 = A2(step_2, a_27, f_25); + var f$_29 = function(){ + switch (_25000_28.ctor) { case 'Tuple2': - return _23000_26._0; - }_E.Case('Line 23, Column 29') }(); - var b_28 = function(){ - switch (_23000_26.ctor) { + return _25000_28._0; + }_E.Case('Line 25, Column 29') }(); + var b_30 = function(){ + switch (_25000_28.ctor) { case 'Tuple2': - return _23000_26._1; - }_E.Case('Line 23, Column 29') }(); - var _24000_29 = A2(step_2, b_28, g_24); - var g$_30 = function(){ - switch (_24000_29.ctor) { + return _25000_28._1; + }_E.Case('Line 25, Column 29') }(); + var _26000_31 = A2(step_2, b_30, g_26); + var g$_32 = function(){ + switch (_26000_31.ctor) { case 'Tuple2': - return _24000_29._0; - }_E.Case('Line 24, Column 29') }(); - var c_31 = function(){ - switch (_24000_29.ctor) { + return _26000_31._0; + }_E.Case('Line 26, Column 29') }(); + var c_33 = function(){ + switch (_26000_31.ctor) { case 'Tuple2': - return _24000_29._1; - }_E.Case('Line 24, Column 29') }(); - return {ctor:"Tuple2", _0:$op['>>>'](f$_27)(g$_30), _1:c_31};}();});}); - $op['<<<'] = F2(function(g_40, f_41){ - return $op['>>>'](f_41)(g_40);}); - var combine_3 = function(autos_42){ - return Step_0(function(a_43){ + return _26000_31._1; + }_E.Case('Line 26, Column 29') }(); + return {ctor:"Tuple2", _0:$op['>>>'](f$_29)(g$_32), _1:c_33};}();});}); + $op['<<<'] = F2(function(g_42, f_43){ + return $op['>>>'](f_43)(g_42);}); + var combine_3 = function(autos_44){ + return Step_0(function(a_45){ return function(){ - var _34000_44 = unzip(A2(map, step_2(a_43), autos_42)); - var autos$_45 = function(){ - switch (_34000_44.ctor) { + var _36000_46 = unzip(A2(map, step_2(a_45), autos_44)); + var autos$_47 = function(){ + switch (_36000_46.ctor) { case 'Tuple2': - return _34000_44._0; - }_E.Case('Line 34, Column 34') }(); - var bs_46 = function(){ - switch (_34000_44.ctor) { + return _36000_46._0; + }_E.Case('Line 36, Column 34') }(); + var bs_48 = function(){ + switch (_36000_46.ctor) { case 'Tuple2': - return _34000_44._1; - }_E.Case('Line 34, Column 34') }(); - return {ctor:"Tuple2", _0:combine_3(autos$_45), _1:bs_46};}();});}; - var pure_4 = function(f_51){ - return Step_0(function(x_52){ - return {ctor:"Tuple2", _0:pure_4(f_51), _1:f_51(x_52)};});}; - var state_5 = F2(function(s_53, f_54){ - return Step_0(function(x_55){ + return _36000_46._1; + }_E.Case('Line 36, Column 34') }(); + return {ctor:"Tuple2", _0:combine_3(autos$_47), _1:bs_48};}();});}; + var pure_4 = function(f_53){ + return Step_0(function(x_54){ + return {ctor:"Tuple2", _0:pure_4(f_53), _1:f_53(x_54)};});}; + var state_5 = F2(function(s_55, f_56){ + return Step_0(function(x_57){ return function(){ - var s$_56 = A2(f_54, x_55, s_53); - return {ctor:"Tuple2", _0:A2(state_5, s$_56, f_54), _1:s$_56};}();});}); - var hiddenState_6 = F2(function(s_57, f_58){ - return Step_0(function(x_59){ + var s$_58 = A2(f_56, x_57, s_55); + return {ctor:"Tuple2", _0:A2(state_5, s$_58, f_56), _1:s$_58};}();});}); + var hiddenState_6 = F2(function(s_59, f_60){ + return Step_0(function(x_61){ return function(){ - var _58000_60 = A2(f_58, x_59, s_57); - var s$_61 = function(){ - switch (_58000_60.ctor) { + var _60000_62 = A2(f_60, x_61, s_59); + var s$_63 = function(){ + switch (_60000_62.ctor) { case 'Tuple2': - return _58000_60._0; - }_E.Case('Line 58, Column 46') }(); - var out_62 = function(){ - switch (_58000_60.ctor) { + return _60000_62._0; + }_E.Case('Line 60, Column 46') }(); + var out_64 = function(){ + switch (_60000_62.ctor) { case 'Tuple2': - return _58000_60._1; - }_E.Case('Line 58, Column 46') }(); - return {ctor:"Tuple2", _0:A2(hiddenState_6, s$_61, f_58), _1:out_62};}();});}); - var enqueue_9 = F2(function(x_69, _67000_70){ + return _60000_62._1; + }_E.Case('Line 60, Column 46') }(); + return {ctor:"Tuple2", _0:A2(hiddenState_6, s$_63, f_60), _1:out_64};}();});}); + var enqueue_9 = F2(function(x_71, _69000_72){ return function(){ - switch (_67000_70.ctor) { + switch (_69000_72.ctor) { case 'Tuple2': - return {ctor:"Tuple2", _0:_L.Cons(x_69,_67000_70._0), _1:_67000_70._1}; - }_E.Case('Line 67, Column 22') }();}); - var dequeue_10 = function(q_73){ + return {ctor:"Tuple2", _0:_L.Cons(x_71,_69000_72._0), _1:_69000_72._1}; + }_E.Case('Line 69, Column 22') }();}); + var dequeue_10 = function(q_75){ return function(){ - switch (q_73.ctor) { + switch (q_75.ctor) { case 'Tuple2': - switch (q_73._0.ctor) { + switch (q_75._0.ctor) { case 'Nil': - switch (q_73._1.ctor) { + switch (q_75._1.ctor) { case 'Nil': return Nothing; }break; } - switch (q_73._1.ctor) { + switch (q_75._1.ctor) { case 'Cons': - return Just({ctor:"Tuple2", _0:q_73._1._0, _1:{ctor:"Tuple2", _0:q_73._0, _1:q_73._1._1}}); + return Just({ctor:"Tuple2", _0:q_75._1._0, _1:{ctor:"Tuple2", _0:q_75._0, _1:q_75._1._1}}); case 'Nil': - return enqueue_9({ctor:"Tuple2", _0:_L.Nil, _1:reverse(q_73._0)}); + return enqueue_9({ctor:"Tuple2", _0:_L.Nil, _1:reverse(q_75._0)}); }break; - }_E.Case('Line 68, Column 13') }();}; - var average_11 = function(k_78){ + }_E.Case('Line 70, Column 13') }();}; + var average_11 = function(k_80){ return function(){ - var step_79 = F2(function(n_81, _78000_82){ + var step_81 = F2(function(n_83, _80000_84){ return function(){ - switch (_78000_82.ctor) { + switch (_80000_84.ctor) { case 'Tuple3': - return (_N.eq(_78000_82._1,k_78)?A2(stepFull_80, n_81, {ctor:"Tuple3", _0:_78000_82._0, _1:_78000_82._1, _2:_78000_82._2}):{ctor:"Tuple2", _0:{ctor:"Tuple3", _0:A2(enqueue_9, n_81, _78000_82._0), _1:(1+_78000_82._1), _2:(_78000_82._2+n_81)}, _1:((_78000_82._2+n_81)/(1+_78000_82._1))}); - }_E.Case('Line 77, Column 11') }();}); - var stepFull_80 = F2(function(n_86, _84000_87){ + return (_N.eq(_80000_84._1,k_80)?A2(stepFull_82, n_83, {ctor:"Tuple3", _0:_80000_84._0, _1:_80000_84._1, _2:_80000_84._2}):{ctor:"Tuple2", _0:{ctor:"Tuple3", _0:A2(enqueue_9, n_83, _80000_84._0), _1:(1+_80000_84._1), _2:(_80000_84._2+n_83)}, _1:((_80000_84._2+n_83)/(1+_80000_84._1))}); + }_E.Case('Line 79, Column 11') }();}); + var stepFull_82 = F2(function(n_88, _86000_89){ return function(){ - switch (_84000_87.ctor) { + switch (_86000_89.ctor) { case 'Tuple3': return function(){ - var case48 = dequeue_10(_84000_87._0); - switch (case48.ctor) { + var case49 = dequeue_10(_86000_89._0); + switch (case49.ctor) { case 'Just': - switch (case48._0.ctor) { + switch (case49._0.ctor) { case 'Tuple2': return function(){ - var sum$_93 = ((_84000_87._2+n_86)-case48._0._0); - return {ctor:"Tuple2", _0:{ctor:"Tuple3", _0:A2(enqueue_9, n_86, case48._0._1), _1:_84000_87._1, _2:sum$_93}, _1:(sum$_93/_84000_87._1)};}(); + var sum$_95 = ((_86000_89._2+n_88)-case49._0._0); + return {ctor:"Tuple2", _0:{ctor:"Tuple3", _0:A2(enqueue_9, n_88, case49._0._1), _1:_86000_89._1, _2:sum$_95}, _1:(sum$_95/_86000_89._1)};}(); }break; case 'Nothing': - return {ctor:"Tuple2", _0:{ctor:"Tuple3", _0:_84000_87._0, _1:_84000_87._1, _2:_84000_87._2}, _1:0}; - }_E.Case('Line 80, Column 11') }(); - }_E.Case('Line 80, Column 11') }();}); - return A2(hiddenState_6, {ctor:"Tuple3", _0:empty_8, _1:0, _2:0}, step_79);}();}; - var count_7 = A2(state_5, 0, function(__67){ - return function(c_68){ - return (1+c_68);};}); + return {ctor:"Tuple2", _0:{ctor:"Tuple3", _0:_86000_89._0, _1:_86000_89._1, _2:_86000_89._2}, _1:0}; + }_E.Case('Line 82, Column 11') }(); + }_E.Case('Line 82, Column 11') }();}); + return A2(hiddenState_6, {ctor:"Tuple3", _0:empty_8, _1:0, _2:0}, step_81);}();}; + var count_7 = A2(state_5, 0, function(__69){ + return function(c_70){ + return (1+c_70);};}); var empty_8 = {ctor:"Tuple2", _0:_L.Nil, _1:_L.Nil}; elm.Native = elm.Native||{}; var _ = elm.Native.Automaton||{}; @@ -3671,44 +3713,51 @@ var N = Elm.Native, _N = N.Utils(elm), _L = N.List(elm), _E = N.Error(elm), _str = N.JavaScript(elm).toString; var $op = {}; var _ = Elm.Signal(elm); var Signal = _; - var lift = _.lift; + var lift = _.lift, dropRepeats = _.dropRepeats; var N = Elm.Native.Graphics.Input(elm); - var id_0 = function(x_9){ - return x_9;}; - var button_1 = function(txt_10){ + var _ = Elm.List(elm); var List = _; + var id_0 = function(x_10){ + return x_10;}; + var button_1 = function(txt_11){ return function(){ - var pool_11 = N.buttons({ctor:"Tuple0"}); - return {ctor:"Tuple2", _0:A2(pool_11.button, {ctor:"Tuple0"}, txt_10), _1:pool_11.events};}();}; - var customButton_2 = F3(function(up_12, hover_13, down_14){ + var pool_12 = N.buttons({ctor:"Tuple0"}); + return {ctor:"Tuple2", _0:A2(pool_12.button, {ctor:"Tuple0"}, txt_11), _1:pool_12.events};}();}; + var customButton_2 = F3(function(up_13, hover_14, down_15){ return function(){ - var pool_15 = N.customButtons({ctor:"Tuple0"}); - return {ctor:"Tuple2", _0:A4(pool_15.button, {ctor:"Tuple0"}, up_12, hover_13, down_14), _1:pool_15.events};}();}); - var checkbox_3 = function(b_16){ + var pool_16 = N.customButtons({ctor:"Tuple0"}); + return {ctor:"Tuple2", _0:A4(pool_16.customButton, {ctor:"Tuple0"}, up_13, hover_14, down_15), _1:pool_16.events};}();}); + var checkbox_3 = function(b_17){ return function(){ - var cbs_17 = N.checkboxes(b_16); - return {ctor:"Tuple2", _0:A2(lift, cbs_17.box(id_0), cbs_17.events), _1:cbs_17.events};}();}; - var FieldState_4 = F3(function(string_18, selectionStart_19, selectionEnd_20){ + var cbs_18 = N.checkboxes(b_17); + return {ctor:"Tuple2", _0:A2(lift, cbs_18.box(id_0), cbs_18.events), _1:cbs_18.events};}();}; + var FieldState_4 = F3(function(string_19, selectionStart_20, selectionEnd_21){ return { _:{ }, - selectionEnd:selectionEnd_20, - selectionStart:selectionStart_19, - string:string_18};}); - var field_6 = function(placeHolder_21){ + selectionEnd:selectionEnd_21, + selectionStart:selectionStart_20, + string:string_19};}); + var field_6 = function(placeHolder_22){ return function(){ - var tfs_22 = N.fields(emptyFieldState_5); - return {ctor:"Tuple2", _0:A2(lift, A2(tfs_22.field, id_0, placeHolder_21), tfs_22.events), _1:A2(lift, function(__23){ - return __23.string;}, tfs_22.events)};}();}; - var password_7 = function(placeHolder_24){ + var tfs_23 = N.fields(emptyFieldState_5); + var changes_24 = dropRepeats(tfs_23.events); + return {ctor:"Tuple2", _0:A2(lift, A2(tfs_23.field, id_0, placeHolder_22), changes_24), _1:dropRepeats(A2(lift, function(__25){ + return __25.string;}, changes_24))};}();}; + var password_7 = function(placeHolder_26){ return function(){ - var tfs_25 = N.passwords(emptyFieldState_5); - return {ctor:"Tuple2", _0:A2(lift, A2(tfs_25.field, id_0, placeHolder_24), tfs_25.events), _1:A2(lift, function(__26){ - return __26.string;}, tfs_25.events)};}();}; - var email_8 = function(placeHolder_27){ + var tfs_27 = N.passwords(emptyFieldState_5); + var changes_28 = dropRepeats(tfs_27.events); + return {ctor:"Tuple2", _0:A2(lift, A2(tfs_27.field, id_0, placeHolder_26), changes_28), _1:dropRepeats(A2(lift, function(__29){ + return __29.string;}, changes_28))};}();}; + var email_8 = function(placeHolder_30){ return function(){ - var tfs_28 = N.emails(emptyFieldState_5); - return {ctor:"Tuple2", _0:A2(lift, A2(tfs_28.field, id_0, placeHolder_27), tfs_28.events), _1:A2(lift, function(__29){ - return __29.string;}, tfs_28.events)};}();}; + var tfs_31 = N.emails(emptyFieldState_5); + var changes_32 = dropRepeats(tfs_31.events); + return {ctor:"Tuple2", _0:A2(lift, A2(tfs_31.field, id_0, placeHolder_30), changes_32), _1:dropRepeats(A2(lift, function(__33){ + return __33.string;}, changes_32))};}();}; + var stringDropDown_9 = function(strs_34){ + return N.dropDown(A2(List.map, function(s_35){ + return {ctor:"Tuple2", _0:s_35, _1:s_35};}, strs_34));}; var emptyFieldState_5 = { _:{ }, @@ -3727,7 +3776,8 @@ _.emptyFieldState = emptyFieldState_5; _.field = field_6; _.password = password_7; - _.email = email_8 + _.email = email_8; + _.stringDropDown = stringDropDown_9 elm.Graphics = elm.Graphics||{}; return elm.Graphics.Input = _; }; @@ -4189,27 +4239,30 @@ var polygon_38 = function(points_94){ return points_94;}; var rect_39 = F2(function(w_95, h_96){ - return _L.Cons({ctor:"Tuple2", _0:(0-(w_95/2)), _1:(0-(h_96/2))},_L.Cons({ctor:"Tuple2", _0:(0-(w_95/2)), _1:(h_96/2)},_L.Cons({ctor:"Tuple2", _0:(w_95/2), _1:(h_96/2)},_L.Cons({ctor:"Tuple2", _0:(w_95/2), _1:(0-(h_96/2))},_L.Nil))));}); - var square_40 = function(n_97){ - return A2(rect_39, w, h);}; - var oval_41 = F2(function(w_98, h_99){ return function(){ - var n_100 = 50; - var t_101 = ((2*Math.PI)/n_100); - var hw_102 = (w_98/2); - var hh_103 = (h_99/2); - var f_104 = function(i_105){ - return {ctor:"Tuple2", _0:(hw_102*Math.cos((t_101*i_105))), _1:(hh_103*Math.sin((t_101*i_105)))};}; - return A2(List.map, f_104, _L.range(0,(n_100-1)));}();}); - var circle_42 = function(r_106){ - return A2(oval_41, (2*r_106), (2*r_106));}; - var ngon_43 = F2(function(n_107, r_108){ + var hw_97 = (w_95/2); + var hh_98 = (h_96/2); + return _L.Cons({ctor:"Tuple2", _0:(0-hw_97), _1:(0-hh_98)},_L.Cons({ctor:"Tuple2", _0:(0-hw_97), _1:hh_98},_L.Cons({ctor:"Tuple2", _0:hw_97, _1:hh_98},_L.Cons({ctor:"Tuple2", _0:hw_97, _1:(0-hh_98)},_L.Nil))));}();}); + var square_40 = function(n_99){ + return A2(rect_39, n_99, n_99);}; + var oval_41 = F2(function(w_100, h_101){ return function(){ - var m_109 = toFloat(n_107); - var t_110 = ((2*Math.PI)/m_109); - var f_111 = function(i_112){ - return {ctor:"Tuple2", _0:(r_108*Math.cos((t_110*i_112))), _1:(r_108*Math.sin((t_110*i_112)))};}; - return A2(List.map, f_111, _L.range(0,(n_107-1)));}();}); + var n_102 = 50; + var t_103 = ((2*Math.PI)/n_102); + var hw_104 = (w_100/2); + var hh_105 = (h_101/2); + var f_106 = function(i_107){ + return {ctor:"Tuple2", _0:(hw_104*Math.cos((t_103*i_107))), _1:(hh_105*Math.sin((t_103*i_107)))};}; + return A2(List.map, f_106, _L.range(0,(n_102-1)));}();}); + var circle_42 = function(r_108){ + return A2(oval_41, (2*r_108), (2*r_108));}; + var ngon_43 = F2(function(n_109, r_110){ + return function(){ + var m_111 = toFloat(n_109); + var t_112 = ((2*Math.PI)/m_111); + var f_113 = function(i_114){ + return {ctor:"Tuple2", _0:(r_110*Math.cos((t_112*i_114))), _1:(r_110*Math.sin((t_112*i_114)))};}; + return A2(List.map, f_113, _L.range(0,(n_109-1)));}();}); var defaultLine_11 = { _:{ },