elm-lang / elm-make

A build tool for Elm projects
BSD 3-Clause "New" or "Revised" License
175 stars 45 forks source link

Send Msgs from debugger (feature request) #138

Closed ghost closed 7 years ago

ghost commented 7 years ago

Rather than the debugger just showing the Msgs that have been sent, it'd be cool if it could also show the Msgs that could be sent, and you could send them by clicking on them. The debugger already shows the model after each Msg, so you could play with your program without having to code the UI.

process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

evancz commented 7 years ago

I'll share this idea with folks who are working on elm-reactor and the debugger.

One issue is that UI messages do not account for all possible messages, so I'm not certain how possible this is in general. Anyway, does not make sense to track on the elm-make repo, but thanks for the suggestion!

ghost commented 7 years ago

This could be used to automatically write tests for you.

Clicking on a Msg would transform the current model into the new model. If the new model is as expected, you could click to say that it is, and that could be used to write a test. To use Counter as an example:

model = 0

update msg model =
  case msg of 
    Up ->
      model + 1
    Down ->
      model - 1

My model starts as 0. I click Up, I get 1. This is as expected so I click to accept. update Up 0 == 1 is now a test that the code has to pass.

ghost commented 7 years ago

I've just realised that this feature is independent of being able to click on Msgs, i.e. it could work with the debugger as it is now. But I don't know where to raise this feature request. Is there a repo I'm missing for the debugger?

ghost commented 7 years ago

Found it: https://github.com/elm-lang/virtual-dom/blob/master/src/VirtualDom/Debug.elm

ghost commented 6 years ago

Sending messages from the debugger would also be good when you can't use your UI to test your program because incoming ports are responsible for getting the UI into a state where it can be used: you could send the messages that the incoming ports would have sent (ports don't work in elm reactor).