Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upImprove documentation of `Debug.watch` #264
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jun 6, 2015
Contributor
I wonder whether it would make sense to even make it illegal to call Debug.watch on something of Signal-type. Could be made a runtime error. Should be unproblematic since Debug.watch shouldn't be used in production anyway. And calling it on a signal is never what you want (because it has no effect). So the debugger would save you some trouble if it simply errored out (with a helpful message) if you accidentally call Debug.watch on a Signal-typed thing.
|
I wonder whether it would make sense to even make it illegal to call |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jun 6, 2015
Contributor
Same (concerning the proposed runtime error) for Debug.watchSummary, of course.
|
Same (concerning the proposed runtime error) for |
jvoigtlaender
referenced this pull request
Jun 6, 2015
Closed
Make it a runtime error to call `Debug.watch` on a `Signal`? #265
mgold
reviewed
Jun 8, 2015
src/Debug.elm
| `Debug.watch` allows us to name the value and show it with the debugger. | ||
| `Debug.watch` allows us to name the value and show it with the debugger. The | ||
| result of evaluating such an expression is exactly the same as if not having | ||
| the call to `Debug.watch` at all. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
Jun 8, 2015
Contributor
Remove "if". Also, "the result of evaluating such an expression" is a bit technical. Maybe just "the value is returned unchanged"?
mgold
Jun 8, 2015
Contributor
Remove "if". Also, "the result of evaluating such an expression" is a bit technical. Maybe just "the value is returned unchanged"?
mgold
reviewed
Jun 8, 2015
src/Debug.elm
| Note that calling `Debug.watch` on a signal is not useful. Instead, it needs | ||
| to be mapped into the signal (to act on the contained value). So if you want | ||
| to watch a timer signal, instead of `Debug.watch "time" <| Time.every second` |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
Jun 8, 2015
Contributor
Both every and second are in the Time module so it doesn't make much sense to have one qualified and one not. For the sake of explanation I would drop the Time. part.
mgold
Jun 8, 2015
Contributor
Both every and second are in the Time module so it doesn't make much sense to have one qualified and one not. For the sake of explanation I would drop the Time. part.
mgold
reviewed
Jun 8, 2015
| That means it's easy to add `Debug.watch` to any value. | ||
| Note that calling `Debug.watch` on a signal is not useful. Instead, it needs | ||
| to be mapped into the signal (to act on the contained value). So if you want |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
Jun 8, 2015
Contributor
Comments inline; hopefully I'm not too nitpicky. I like where this is going.
|
Comments inline; hopefully I'm not too nitpicky. I like where this is going. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jun 8, 2015
Contributor
I reformulated a few bits. I do think that "mapped into" is better here.
|
I reformulated a few bits. I do think that "mapped into" is better here. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
mgold
Jun 9, 2015
Contributor
I won't fight you on it then. Should be good for whenever Evan gets back from his world tour.
|
I won't fight you on it then. Should be good for whenever Evan gets back from his world tour. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Looks great to me, thank you @jvoigtlaender! |
jvoigtlaender commentedJun 6, 2015
Specifically, it is tempting to call
Debug.watchdirectly on a signal, which is not useful though. That can lead to puzzlement, since it then seems as ifDebug.watchserves no purpose. See this question on the mailing list. The expanded documentation should make clear now that one needs to mapDebug.watchinto the signal if one wants to observe the value carried on the signal.