Created
January 26, 2023 16:19
-
-
Save joakin/8d4ea1b13cfb0322a51ece6ba540ee33 to your computer and use it in GitHub Desktop.
Debug Json decoders helpers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
log : String -> Json.Decode.Decoder a -> Json.Decode.Decoder a | |
log message = | |
Json.Decode.map (Debug.log message) | |
debug : String -> Json.Decode.Decoder a -> Json.Decode.Decoder a | |
debug message decoder = | |
Json.Decode.value | |
|> Json.Decode.andThen (debugHelper message decoder) | |
debugHelper : String -> Json.Decode.Decoder a -> Json.Decode.Value -> Json.Decode.Decoder a | |
debugHelper message decoder value = | |
let | |
_ = | |
Debug.log message (Json.Decode.decodeValue decoder value) | |
in | |
decoder | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment