@@ -47,7 +47,6 @@ import Language.PureScript.CodeGen.Optimize
48moduleToJs :: Options -> Module -> Environment -> [JS]
48moduleToJs :: Options -> Module -> Environment -> [JS]
49moduleToJs opts (Module pname@(ProperName name) decls) env =
49moduleToJs opts (Module pname@(ProperName name) decls) env =
50− mapMaybe filterRawDecls decls ++
51 [ JSVariableIntroduction (Ident name) Nothing
50 [ JSVariableIntroduction (Ident name) Nothing
52 , JSApp (JSFunction Nothing [Ident name]
51 , JSApp (JSFunction Nothing [Ident name]
53 (JSBlock (concat $ mapMaybe (\decl -> fmap (map $ optimize opts) $ declToJs opts (ModuleName pname) decl env) (sortBy typeClassesLast decls))))
52 (JSBlock (concat $ mapMaybe (\decl -> fmap (map $ optimize opts) $ declToJs opts (ModuleName pname) decl env) (sortBy typeClassesLast decls))))
@@ -55,8 +54,6 @@ moduleToJs opts (Module pname@(ProperName name) decls) env =
55 (JSBinary Or (JSVar (Ident name)) (JSObjectLiteral []))]
54 (JSBinary Or (JSVar (Ident name)) (JSObjectLiteral []))]
58− filterRawDecls (ExternDeclaration ForeignImport _ (Just js) _) = Just js
59− filterRawDecls _ = Nothing
60 typeClassesLast (ExternDeclaration TypeClassDictionaryImport _ _ _) (ExternDeclaration TypeClassDictionaryImport _ _ _) = EQ
57 typeClassesLast (ExternDeclaration TypeClassDictionaryImport _ _ _) (ExternDeclaration TypeClassDictionaryImport _ _ _) = EQ
61 typeClassesLast (ExternDeclaration TypeClassDictionaryImport _ _ _) _ = GT
58 typeClassesLast (ExternDeclaration TypeClassDictionaryImport _ _ _) _ = GT
62 typeClassesLast _ (ExternDeclaration TypeClassDictionaryImport _ _ _) = LT
59 typeClassesLast _ (ExternDeclaration TypeClassDictionaryImport _ _ _) = LT
@@ -87,7 +84,7 @@ declToJs _ mp (DataDeclaration _ _ ctors) _ =
87 in [ ctorJs, setProperty ctor (JSVar (Ident ctor)) mp ]
84 in [ ctorJs, setProperty ctor (JSVar (Ident ctor)) mp ]
88declToJs opts mp (DataBindingGroupDeclaration ds) e =
85declToJs opts mp (DataBindingGroupDeclaration ds) e =
89 Just $ concat $ mapMaybe (flip (declToJs opts mp) e) ds
86 Just $ concat $ mapMaybe (flip (declToJs opts mp) e) ds
90−declToJs _ mp (ExternDeclaration importTy ident (Just js) _) _ | importTy /= ForeignImport =
87+declToJs _ mp (ExternDeclaration importTy ident (Just js) _) _ =
92 , setProperty (identToJs ident) (JSVar ident) mp ]
89 , setProperty (identToJs ident) (JSVar ident) mp ]
93declToJs _ _ _ _ = Nothing
90declToJs _ _ _ _ = Nothing