@@ -50,7 +50,7 @@ moduleToCpp
50 => Module Ann
50 => Module Ann
51 -> Maybe AST
51 -> Maybe AST
52 -> m (Text, [Text], [AST], Text, Text)
52 -> m (Text, [Text], [AST], Text, Text)
53−moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
53+moduleToCpp (Module _ coms mn _ imps _ foreigns decls) _ =
55 let usedNames = concatMap getNames decls
55 let usedNames = concatMap getNames decls
56 let mnLookup = renameImports usedNames imps
56 let mnLookup = renameImports usedNames imps
@@ -60,9 +60,9 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
60 cppDecls <- mapM (bindToCpp ModuleDecl) decls'
60 cppDecls <- mapM (bindToCpp ModuleDecl) decls'
61 optimized <- traverse (traverse (optimize modName')) cppDecls
61 optimized <- traverse (traverse (optimize modName')) cppDecls
62 let optimized' = concat optimized
62 let optimized' = concat optimized
63− exports' = mapMaybe (export $ identToCpp <$> exports) optimized'
63+ values = annotValue <$> optimized'
64 foreigns' = identToCpp <$> foreigns
64 foreigns' = identToCpp <$> foreigns
65− interface = interfaceSource modName exports' foreigns
65+ interface = interfaceSource modName values foreigns
66 implHeader = implHeaderSource modName cppImports interfaceImport
66 implHeader = implHeaderSource modName cppImports interfaceImport
67 implFooter = implFooterSource modName foreigns
67 implFooter = implFooterSource modName foreigns
68 return $ (interface, foreigns', optimized', implHeader, implFooter)
68 return $ (interface, foreigns', optimized', implHeader, implFooter)
@@ -70,12 +70,11 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
70 modName = moduleNameToCpp mn
70 modName = moduleNameToCpp mn
71 modName' = AST.Var Nothing modName
71 modName' = AST.Var Nothing modName
73− export :: [Text] -> AST -> Maybe (Text, Bool)
73+ annotValue :: AST -> (Text, Bool)
74− export names (AST.Function _ (Just name) [] (AST.Block _ [AST.Return _ ret]))
74+ annotValue (AST.Function _ (Just name) [] (AST.Block _ [AST.Return _ ret]))
75− | name `elem` names && isLiteral ret = Just (name, True)
75+ | isLiteral ret = (name, True)
76− export names (AST.Function _ (Just name) [] _)
76+ annotValue (AST.Function _ (Just name) [] _) = (name, False)
77− | name `elem` names = Just (name, False)
77+ annotValue _ = error "Unexpected top-level value form"
80 -- | Extracts all declaration names from a binding group.
79 -- | Extracts all declaration names from a binding group.
81 getNames :: Bind Ann -> [Ident]
80 getNames :: Bind Ann -> [Ident]