Skip to content

Instantly share code, notes, and snippets.

@moritzmhmk
Created November 10, 2021 17:18
Show Gist options
  • Save moritzmhmk/86d78cc6b8076ee7a10c40085e23409c to your computer and use it in GitHub Desktop.
Save moritzmhmk/86d78cc6b8076ee7a10c40085e23409c to your computer and use it in GitHub Desktop.
Elm Utils
-- source: https://thoughtbot.com/blog/debugging-dom-event-handlers-in-elm
loggingDecoder : Decoder a -> Decoder a
loggingDecoder realDecoder =
Decode.value
|> Decode.andThen
(\event ->
case Decode.decodeValue realDecoder event of
Ok decoded ->
Decode.succeed decoded
Err error ->
error
|> Decode.errorToString
|> Debug.log "decoding error"
|> Decode.fail
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment