@@ -56,14 +56,15 @@ checkMainType typeEnv decls =
5656 A.A (region,_) (Decl.Def (Valid.Definition (A.A _ (P.Var "main")) _ _)) : _ ->
5757 case Map.lookup "main" typeEnv of
5858 Nothing ->
59− return ()
59+ return ()
60+
61+ Just tipe ->
62+ case Type.deepDealias tipe of
63+ Type.App (Type.Type name) [_] | name == virtualDomNode ->
64+ return ()
6065
61− Just typeOfMain ->
62− let tipe = Type.deepDealias typeOfMain
63− in
64− if tipe `elem` validMainTypes
65− then return ()
66− else Result.throw region (Error.BadMain typeOfMain)
66+ _ ->
67+ Result.throw region (Error.BadMain tipe)
6768
6869 _ : remainingDecls ->
6970 checkMainType typeEnv remainingDecls
@@ -72,37 +73,9 @@ checkMainType typeEnv decls =
7273 return ()
7374
7475
75−validMainTypes :: [Type.Canonical]
76−validMainTypes =
77− [ element
78− , html
79− , signal element
80− , signal html
81− ]
82−
83−
84−html :: Type.Canonical
85−html =
86− Type.Type (Var.fromModule virtualDom "Node")
87−
88−
89−virtualDom :: ModuleName.Canonical
90−virtualDom =
91− ModuleName.Canonical (Pkg.Name "evancz" "virtual-dom") ["VirtualDom"]
92−
93−
94−element :: Type.Canonical
95−element =
96− core ["Graphics","Element"] "Element"
97−
98−
99−signal :: Type.Canonical -> Type.Canonical
100−signal tipe =
101− Type.App (core ["Signal"] "Signal") [ tipe ]
102−
103−
104−core :: [String] -> String -> Type.Canonical
105−core home name =
106− Type.Type (Var.inCore home name)
107−
76+virtualDomNode :: Var.Canonical
77+virtualDomNode =
78+ Var.fromModule
79+ (ModuleName.Canonical (Pkg.Name "evancz" "virtual-dom") ["VirtualDom"])
80+ "Node"
10881