@@ -50,7 +50,7 @@ moduleToCpp
5050 => Module Ann
5151 -> Maybe AST
5252 -> m (Text, [Text], [AST], Text, Text)
53−moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
53+moduleToCpp (Module _ coms mn _ imps _ foreigns decls) _ =
5454 do
5555 let usedNames = concatMap getNames decls
5656 let mnLookup = renameImports usedNames imps
@@ -60,9 +60,9 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
6060 cppDecls <- mapM (bindToCpp ModuleDecl) decls'
6161 optimized <- traverse (traverse (optimize modName')) cppDecls
6262 let optimized' = concat optimized
63− exports' = mapMaybe (export $ identToCpp <$> exports) optimized'
63+ values = annotValue <$> optimized'
6464 foreigns' = identToCpp <$> foreigns
65− interface = interfaceSource modName exports' foreigns
65+ interface = interfaceSource modName values foreigns
6666 implHeader = implHeaderSource modName cppImports interfaceImport
6767 implFooter = implFooterSource modName foreigns
6868 return $ (interface, foreigns', optimized', implHeader, implFooter)
@@ -70,12 +70,11 @@ moduleToCpp (Module _ coms mn _ imps exports foreigns decls) _ =
7070 modName = moduleNameToCpp mn
7171 modName' = AST.Var Nothing modName
7272
73− export :: [Text] -> AST -> Maybe (Text, Bool)
74− export names (AST.Function _ (Just name) [] (AST.Block _ [AST.Return _ ret]))
75− | name `elem` names && isLiteral ret = Just (name, True)
76− export names (AST.Function _ (Just name) [] _)
77− | name `elem` names = Just (name, False)
78− export _ _ = Nothing
73+ annotValue :: AST -> (Text, Bool)
74+ annotValue (AST.Function _ (Just name) [] (AST.Block _ [AST.Return _ ret]))
75+ | isLiteral ret = (name, True)
76+ annotValue (AST.Function _ (Just name) [] _) = (name, False)
77+ annotValue _ = error "Unexpected top-level value form"
7978
8079 -- | Extracts all declaration names from a binding group.
8180 getNames :: Bind Ann -> [Ident]