on master help sign in
Add `Touch` and `TextState` aliases.
commitef1275e5a1e3ef643322fd27d0f52bcf12e8f6bb authorevancz <info@elm-lang.org> dateSat 4 May 2013, 18:58 (14 years ago) parentb359fd0
2 files changed+9−7
compiler/Types/Alias.hs+8−2 libraries/Graphics/Input.elm+1−5
compiler/Types/Alias.hs+8−2
@@ -10,8 +10,14 @@ import Types.Substitutions (subst)
1010import Types.Types
1111
1212builtins :: [(String,([X],Type))]
13−builtins = [ ("String", ([], listOf char))
14− , ("Time", ([], float)) ]
13+builtins =
14+ let touch = ("t0", time) : map (flip (,) int) ["x","y","x0","y0","id"]
15+ state = [("text", string), ("start", int), ("end", int)]
16+ in [ ("String", ([], listOf char))
17+ , ("Time", ([], float))
18+ , ("Touch", ([], RecordT (Map.fromString touch) EmptyRecord))
19+ , ("TextState", ([], RecordT (Map.fromString state) EmptyRecord))
20+ ]
1521
1622get :: [Statement] -> Map.Map String ([X],Type)
1723get stmts = Map.fromList (builtins ++ concatMap getAlias stmts)
libraries/Graphics/Input.elm+1−5
@@ -28,11 +28,7 @@ checkBox b =
2828 let cbs = N.checkBoxes b
2929 in (lift (cbs.box id) cbs.events, cbs.events)
3030
31−type TextState = {
32− input : String,
33− start : Int,
34− end : Int
35− }
31+type TextState = { text:String, start:Int, end:Int }
3632
3733textFields : a -> { field : (TextState -> a) -> String -> TextState -> Element,
3834 events : Signal a }