on master help sign in
Better comments for new Debug functions
3b4b353Evan Czaplicki
libraries/Debug.elm+25−3
@@ -50,17 +50,39 @@ Use the `Maybe` or `Either` libraries instead.
50crash : String -> a
50crash : String -> a
51crash = Native.Error.raise
51crash = Native.Error.raise
52
52
53−{-| Watch a particular value in the reactive debugger.
53+{-| Watch a particular value in the debugger. Say we want to know the value of
54+a variable called `velocity` because it may not be updated correctly. Adding
55+`Debug.watch` allows us to name the value and show it with the debugger.
56+
57+ Debug.watch "velocity" velocity == velocity
58+
59+Notice that the result of evaluating this expression is exactly the same as
60+not having the expression at all. That means it's easy to add to any value.
54-}
61-}
55watch : String -> a -> a
62watch : String -> a -> a
56watch = Native.Debug.watch
63watch = Native.Debug.watch
57
64
58−{-| Watch a particular value in the reactive debugger.
65+{-| Watch a summary of a particular value in the debugger. This function is
66+pretty much the same as `watch` but it lets you specify a way to summarize
67+the value you are interested in. For example, maybe you only want to see part
68+of a record:
69+
70+ Debug.watchSummary "velocity" .velocity object
71+
72+This is the same as just writing `object`, but it creates a watch that *only*
73+looks at the value of `object.velocity`. You can also show summary statistics
74+like length of a list:
75+
76+ Debug.watchSummary "Number of clicks" length clicks
77+
78+Again, this evaluates to `clicks` but we get to see how long that list is in
79+the debugger.
59-}
80-}
60watchSummary : String -> (a -> b) -> a -> a
81watchSummary : String -> (a -> b) -> a -> a
61watchSummary = Native.Debug.watchSummary
82watchSummary = Native.Debug.watchSummary
62
83
63−{-| Trace a Form over time in the reactive debugger.
84+{-| Trace all past positions of a `Form` in the debugger. Add this to a `Form`
85+and you will see a line tracing its entire history.
64-}
86-}
65trace : String -> Form -> Form
87trace : String -> Form -> Form
66trace = Native.Debug.tracePath
88trace = Native.Debug.tracePath