Debug.watch doesn't appear in elm-reactor

221 views
Skip to first unread message

aphorisme

unread,
Jun 6, 2015, 7:42:11 AM6/6/15
to elm-d...@googlegroups.com
Sorry, if this is a duplicate, but haven't found something on this topic so far.


For Debugging purpose I want to use 'Debug.watch'. It looks as if I could just wrap it around a value I want to watch over time. So, in a naive try, I just did wrap it around my model:

> main : Signal Html
> main = Signal.map (view actions.address) (Debug.watch "UIModel:" model)

If I point to this app in the elm-reactor via the wrench, I still got the message "You don't have any watches!" Even when I'm trying to wrap other values, it keeps saying that.

What am I doing wrong?

Janis Voigtländer

unread,
Jun 6, 2015, 2:53:41 PM6/6/15
to elm-d...@googlegroups.com

I guess the problem is that you are trying to apply Debug.watch on a Signal, but it is meant for being applied to simple values (typically inside signals). Try this variant of your code:

main : Signal Html
main = Signal.map (\m -> view actions.address (Debug.watch "UIModel:" m)) model

--
You received this message because you are subscribed to the Google Groups "Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elm-discuss...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Janis Voigtländer

unread,
Jun 6, 2015, 2:57:15 PM6/6/15
to elm-d...@googlegroups.com

Or, if you prefer (and being syntactically closer to your original version):

main : Signal Html
main = Signal.map (view actions.address) (Debug.watch "UIModel:" <~ model)

Janis Voigtländer

unread,
Jun 6, 2015, 3:31:21 PM6/6/15
to elm-d...@googlegroups.com

Would my proposed change to the documentation of Debug.watch in this pull request have saved you some trouble?

aphorisme

unread,
Jul 8, 2015, 12:51:58 PM7/8/15
to elm-d...@googlegroups.com
Definitely. Thanks!
I would also like to propose that the message in the debug mode gets changed. That it kept saying: "You don't have any watches!" if I've added some (on a Signal) did confuse me a lot.

Max Goldstein

unread,
Jul 8, 2015, 1:17:41 PM7/8/15
to elm-d...@googlegroups.com
The "You don't have any watches" message more accurately means "The debugger has not received any watch messages yet". If you're watching a filtered or rarely-updating signal, it can be some time until a watch event comes through.

I support changing the message if it can be done unobtrusively, and the PR that's out to make it crash on signals.

aphorisme

unread,
Jul 8, 2015, 5:12:27 PM7/8/15
to elm-d...@googlegroups.com
Thanks  : )

Pete Vilter

unread,
Jul 8, 2015, 7:06:00 PM7/8/15
to elm-d...@googlegroups.com
Hi, I'm currently working on the reactor. I agree that "you don't have any watches" is sometimes misleading; filed a bug for that here and I'm trying to figure out how to fix it!

Also, I initially found it unintuitive that watching signals didn't work; I think that should work (perhaps with variant `Debug.watchSignal`). Will be thinking about this as well! Currently just trying to fix some basic reactor bugs, so probably won't get there for a while.

—Pete

On Wednesday, July 8, 2015 at 2:12:27 PM UTC-7, aphorisme wrote:
Thanks  : )
Reply all
Reply to author
Forward
0 new messages