让我们说我有两种类型的别名:
type alias A = {...}
type alias B = {...}
和联合类型
type Content = A | B
和模型类型
type alias Model= {cont : Content, ...}
init : Content -> Model
init cont = {cont = cont, ...}
如何将类型A的记录传递给init.
a : A
a = {...}
init a 
抛出以下错误:
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
我认为A是内容的一种"子类型".我不能写
a:Content
a = {...}
init a
因为有些逻辑会对内容进行案例分析
榆树的联盟类型是所谓的歧视联盟(或标记的联盟).区分部分是标签或构造函数.在这种情况下,我认为你想要:
type Content = TagA A | TagB B
请注意,第一个大写名称是标记,其他任何类型或类型变量.
现在你可以这样做:
a : A
a = { ... }
init (TagA a)
在init您可以通过区分这两种类型:
init content =
  case content of
    TagA a -> ...
    TagB b -> ...