Lets's say I have two type aliases:
type alias A = {...}
type alias B = {...}
and a union type
type Content = A | B
and a model type
type alias Model= {cont : Content, ...}
init : Content -> Model
init cont = {cont = cont, ...}
How do I pass a record of type A to init.
a : A
a = {...}
init a
throws the following error:
Detected errors in 1 module.
## ERRORS in Main.elm ##########################################################
-- TYPE MISMATCH ------------------------------------------------------ Main.elm
The 1st argument to function `init` has an unexpected type.
78| init e
^
As I infer the type of values flowing through your program, I see a conflict
between these two types:
Content
A
I would imagine that A is a kind of "subtype" of Content. I can't just write
a:Content
a = {...}
init a
because some of the logic does case analysis on Content
type Content = modulename.A | modulename.B. The problem is that those types can't really be brought in to the module. I could make some kind of proxy type I suppose. What do you think? - Michiel Ariens