on master help sign in
Make docs nicer based on comments on list!
cc3c870Evan Czaplicki
libraries/Graphics/Input.elm+12−9
@@ -45,14 +45,17 @@ type Input a = { signal : Signal a, handle : Handle a }
45
45
46data Handle a = Handle
46data Handle a = Handle
47
47
48−{-| Create a new `Input`. You just give the initial value for the
48+{-| This creates a new `Input`. You provide a single argument that will serve
49−input’s `signal`.
49+as the initial value of the input’s `signal`. For example:
50−
50+
51−Note for Advanced Users: creating an `Input` is an inherently imperative
51+ numbers : Input Int
52−action, so this is one of very few impure functions in Elm. That means
52+ numbers = input 42
53+
54+The initial value of `numbers.signal` is 42, and you will be able
55+to pipe updates to the input using `numbers.handle`.
56+
57+Note: This is an inherently impure function. Specifically, `(input ())` and
53−`(input ())` and `(input ())` are actually two different inputs with different
58+`(input ())` are actually two different inputs with different signals and handles.
54−signals and handles. By design, Elm’s impure functions can only be useful
55−as you build your signal graph at startup, so Elm is still pure at runtime.
56-}
59-}
57input : a -> Input a
60input : a -> Input a
58input = Native.Graphics.Input.input
61input = Native.Graphics.Input.input
@@ -208,7 +211,7 @@ to match what they have entered.
208 name = input noContent
211 name = input noContent
209
212
210 nameField : Signal Element
213 nameField : Signal Element
211− nameField = field name.handle (\content -> content) "Name" <~ nameContent
214+ nameField = field name.handle id "Name" <~ name.signal
212-}
215-}
213field : Handle a -> (FieldContent -> a) -> String -> FieldContent -> Element
216field : Handle a -> (FieldContent -> a) -> String -> FieldContent -> Element
214field = Native.Graphics.Input.field
217field = Native.Graphics.Input.field