{"action":"created","issue":{"url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/1244","labels_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/1244/labels{/name}","comments_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/1244/comments","events_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/1244/events","html_url":"https://github.com/elm-lang/elm-compiler/issues/1244","id":124467388,"number":1244,"title":"decoder is not a function","user":{"login":"bartavelle","id":1183983,"avatar_url":"https://avatars.githubusercontent.com/u/1183983?v=3","gravatar_id":"","url":"https://api.github.com/users/bartavelle","html_url":"https://github.com/bartavelle","followers_url":"https://api.github.com/users/bartavelle/followers","following_url":"https://api.github.com/users/bartavelle/following{/other_user}","gists_url":"https://api.github.com/users/bartavelle/gists{/gist_id}","starred_url":"https://api.github.com/users/bartavelle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bartavelle/subscriptions","organizations_url":"https://api.github.com/users/bartavelle/orgs","repos_url":"https://api.github.com/users/bartavelle/repos","events_url":"https://api.github.com/users/bartavelle/events{/privacy}","received_events_url":"https://api.github.com/users/bartavelle/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-31T12:40:49Z","updated_at":"2016-01-01T16:05:43Z","closed_at":null,"body":"Here is a minimal test case:\r\n\r\n\r\n    module Main where\r\n    \r\n    import Html exposing (div, text)\r\n\r\n    import Json.Decode exposing (..)\r\n    import Dict exposing (Dict)\r\n    \r\n    type Rec = A Int\r\n             | R (List Rec)\r\n    \r\n    decodeSumObjectWithSingleField : String -> Dict String (Decoder a) -> Decoder a\r\n    decodeSumObjectWithSingleField name mapping = keyValuePairs value `customDecoder` \\lst -> case lst of\r\n        [(key,value)] -> decodeSumFinal name key value mapping\r\n        _ -> Err (\"Can't decode \" ++ name ++ \": object has too many keys\")\r\n    \r\n    decodeSumFinal : String -> String -> Value -> Dict String (Json.Decode.Decoder a) -> Result String a\r\n    decodeSumFinal name key value mapping =\r\n        case Dict.get key mapping of\r\n            Nothing -> Err (\"Unknown constructor \" ++ key ++ \" for type \" ++ name)\r\n            Just dec -> Json.Decode.decodeValue dec value\r\n    \r\n    decRec : Decoder Rec\r\n    decRec =\r\n        let dic = Dict.fromList\r\n                    [ (\"A\", map A int)\r\n                    , (\"R\", map R (list decRec))\r\n                    ]\r\n        in  decodeSumObjectWithSingleField \"Rec\" dic\r\n    \r\n    sample : String\r\n    sample = \"{\\\"R\\\":[{\\\"A\\\":1}]}\"\r\n    \r\n    main : Html.Html\r\n    main = div [] [text <| toString <| decodeString decRec sample]\r\n\r\nIt displays `Err (\"custom decoder failed: decoder is not a function\")` instead of the expected decoded output. I think this is related to #873, but I really am not sure."},"comment":{"url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/comments/168314206","html_url":"https://github.com/elm-lang/elm-compiler/issues/1244#issuecomment-168314206","issue_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/1244","id":168314206,"user":{"login":"mgold","id":1191970,"avatar_url":"https://avatars.githubusercontent.com/u/1191970?v=3","gravatar_id":"","url":"https://api.github.com/users/mgold","html_url":"https://github.com/mgold","followers_url":"https://api.github.com/users/mgold/followers","following_url":"https://api.github.com/users/mgold/following{/other_user}","gists_url":"https://api.github.com/users/mgold/gists{/gist_id}","starred_url":"https://api.github.com/users/mgold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgold/subscriptions","organizations_url":"https://api.github.com/users/mgold/orgs","repos_url":"https://api.github.com/users/mgold/repos","events_url":"https://api.github.com/users/mgold/events{/privacy}","received_events_url":"https://api.github.com/users/mgold/received_events","type":"User","site_admin":false},"created_at":"2016-01-01T16:05:43Z","updated_at":"2016-01-01T16:05:43Z","body":"Anyone have any idea how to get this down to an [SSCCE](http://sscce.org/)?\r\n\r\nI can guess that some kind of JS runtime error is occurring, which is caught and turned into an `Err`."}}