I have a type defined as inside module Foo exposing (..) :
type Foo = Bar { a : String , b : String } | Baz ...
Then I tried to create a Json Decoder in a separate module to decode this type:
barDecoder : Decoder Bar barDecoder = map2 Bar (field "a" string) (field "b" string)
The Elm compiler gives me an error in the map2 Bar line saying that the type Bar not found. The module containing the decoder has import Foo exposing (..) . I also tried to move this function to the same module that contains the type definition and get the same error, so it has nothing to do with being in a separate module.
I tried changing it to map2 Foo.Bar , but that didn't work either.
What is the correct way to decode this type of join?
source share