First, let me say great work. I've really enjoyed working with servant-elm so far.
The only trouble I've run into so far with servant-elm occurs when the api for which I'm generating elm code involves algebraic sum types in some way.
E.g. Let's say my api looks like this:
type NameCompletionAPI = "nameCompletion" :> ReqBody '[JSON] NameCompletionRequest :> Get '[JSON] [Name]
And suppose the NameCompletionRequest type looks like this:
data NameCompletionRequest = NameCompletionRequest { nameSubstring :: Text , fromNationality :: Nationality , position :: Position } deriving (Generic)
and Position is a simple algebraic sum type:
data Position = Beginning | Middle | End deriving (Eq, Generic)
(Suppose too Nationality is just a new type wrapper around Text, and that we've defined all the ToJSON, FromJSON, and ElmType or ToElmType instances for these data types.)
Then on the main branch, when I go to generate this code, I'll get something like:
*** Exception: toElmTypeWithSources: Sum (Constructor "Beginning" Unit) (Sum (Constructor "Middle" Unit) (Constructor "End" Unit))
And on the devel branch, I'll get something like:
*** Exception: src/Elm/Encoder.hs:(13,1)-(58,28): Non-exhaustive patterns in function render
I was wondering if support for algebraic sum types was in the cards any time soon.
I guess this may be fundamentally more of an issue with elm-export. Let me know if it's best brought up somewhere else.
First, let me say great work. I've really enjoyed working with servant-elm so far.
The only trouble I've run into so far with servant-elm occurs when the api for which I'm generating elm code involves algebraic sum types in some way.
E.g. Let's say my api looks like this:
type NameCompletionAPI = "nameCompletion" :> ReqBody '[JSON] NameCompletionRequest :> Get '[JSON] [Name]And suppose the NameCompletionRequest type looks like this:
data NameCompletionRequest = NameCompletionRequest { nameSubstring :: Text , fromNationality :: Nationality , position :: Position } deriving (Generic)and Position is a simple algebraic sum type:
data Position = Beginning | Middle | End deriving (Eq, Generic)(Suppose too
Nationalityis just a new type wrapper aroundText, and that we've defined all theToJSON,FromJSON, andElmTypeorToElmTypeinstances for these data types.)Then on the main branch, when I go to generate this code, I'll get something like:
*** Exception: toElmTypeWithSources: Sum (Constructor "Beginning" Unit) (Sum (Constructor "Middle" Unit) (Constructor "End" Unit))And on the devel branch, I'll get something like:
*** Exception: src/Elm/Encoder.hs:(13,1)-(58,28): Non-exhaustive patterns in function renderI was wondering if support for algebraic sum types was in the cards any time soon.
I guess this may be fundamentally more of an issue with elm-export. Let me know if it's best brought up somewhere else.