on master help sign in
Add `Touch` and `TextState` aliases.
ef1275eevancz
compiler/Types/Alias.hs+8−2
@@ -10,8 +10,14 @@ import Types.Substitutions (subst)
10import Types.Types
10import Types.Types
11
11
12builtins :: [(String,([X],Type))]
12builtins :: [(String,([X],Type))]
13+builtins =
14+ let touch = ("t0", time) : map (flip (,) int) ["x","y","x0","y0","id"]
15+ state = [("text", string), ("start", int), ("end", int)]
13−builtins = [ ("String", ([], listOf char))
16+ in [ ("String", ([], listOf char))
14− , ("Time", ([], float)) ]
17+ , ("Time", ([], float))
18+ , ("Touch", ([], RecordT (Map.fromString touch) EmptyRecord))
19+ , ("TextState", ([], RecordT (Map.fromString state) EmptyRecord))
20+ ]
15
21
16get :: [Statement] -> Map.Map String ([X],Type)
22get :: [Statement] -> Map.Map String ([X],Type)
17get stmts = Map.fromList (builtins ++ concatMap getAlias stmts)
23get stmts = Map.fromList (builtins ++ concatMap getAlias stmts)
libraries/Graphics/Input.elm+1−5
@@ -28,11 +28,7 @@ checkBox b =
28 let cbs = N.checkBoxes b
28 let cbs = N.checkBoxes b
29 in (lift (cbs.box id) cbs.events, cbs.events)
29 in (lift (cbs.box id) cbs.events, cbs.events)
30
30
31−type TextState = {
31+type TextState = { text:String, start:Int, end:Int }
32− input : String,
33− start : Int,
34− end : Int
35− }
36
32
37textFields : a -> { field : (TextState -> a) -> String -> TextState -> Element,
33textFields : a -> { field : (TextState -> a) -> String -> TextState -> Element,
38 events : Signal a }
34 events : Signal a }