Skip to content

Instantly share code, notes, and snippets.

@mrmurphy
Created June 20, 2016 12:46
Show Gist options
  • Save mrmurphy/0e7260d79b7b59c1dbb9ad962dbbba79 to your computer and use it in GitHub Desktop.
Save mrmurphy/0e7260d79b7b59c1dbb9ad962dbbba79 to your computer and use it in GitHub Desktop.
Decoding Ints
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