Created
June 20, 2016 12:46
-
-
Save mrmurphy/0e7260d79b7b59c1dbb9ad962dbbba79 to your computer and use it in GitHub Desktop.
Decoding Ints
This file contains hidden or 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
import Html exposing (text) | |
import Json.Decode exposing (Decoder, decodeString, list, int) | |
-- Define a "recipe" (decoder) | |
-- Execute the recipe (decoder) | |
-- Result x a = Err x | Ok a | |
num = "4" | |
nums = "[1,3,5,6,7]" | |
numbersDecoder : Decoder (List Int) | |
numbersDecoder = list int | |
decoded : Result String (List Int) | |
decoded = decodeString numbersDecoder nums | |
main = text (toString decoded) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment