DEV Community

Discussion on: #30daysofelm Day 26: Debug.log, Debug.toString and the REPL

Collapse
 
wolfadex profile image
Wolfgang Schuster

In Elm, Debug.log has to be within a let block.

That's not accurate, though it is common. Debug.log has the type Debug.log : String -> a -> a which means it takes a String and anything and returns that last thing. This can be really handy with pipes as an example

myThing
    |> doSomething
    |> Debug.log "my modified thing"
    |> otherFunc
    |> Debug.log "after otherFunc change"
Enter fullscreen mode Exit fullscreen mode

This way you can log your thing between steps. Another example could be wanting to log the value being passed into a case .. of

case Debug.log "my value" someVal of
    ...
Enter fullscreen mode Exit fullscreen mode

Also kinda sad that this series is almost over!

Collapse
 
kristianpedersen profile image
Kristian Pedersen

Ah, thanks! As always, your input is highly appreciated!

It does feel weird that the 30 days are almost done. Maybe 30 weeks next? :D

I'm happy though - I can easily spend 10-15 minutes re-writing a paragraph, so it will be nice to have more energy to focus on code and projects. :)

Writing is a great tool for learning, so I wouldn't be surprised if I make more posts.