Decode UndoList submodule.
Provides JSON decoders for Timelines and UndoList Messages.
undolist : Json.Decode.Decoder state -> Json.Decode.Decoder (UndoList state)
Decode an undo-list given a decoder of state.
import Json.Decode
json : String
json = """{
"past": [ 1, 2 ],
"present": 3,
"future": [ 4, 5 ]
}"""
Json.Decode.decodeString (undolist Json.Decode.int) json
--> Ok { past = [ 1, 2 ], present = 3, future = [ 4, 5 ] }
msg : Json.Decode.Decoder msg -> Json.Decode.Decoder (UndoList.Msg msg)
Decode an undo-list msg given a decoder of messages.
import Json.Decode
import UndoList exposing (Msg(..))
Json.Decode.decodeString (msg Json.Decode.string) "{ \"New\": \"Hello!\" }"
--> Ok (New "Hello!")
json : String
json = """[ "Reset", "Redo", "Undo", "Forget", { "New": 1 } ]"""
Json.Decode.decodeString (Json.Decode.list <| msg Json.Decode.int) json
--> Ok [ Reset, Redo, Undo, Forget, New 1 ]