@@ -65,7 +65,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
65 cppImports <-
65 cppImports <-
66 traverse (pure . runModuleName) .
66 traverse (pure . runModuleName) .
67 delete (ModuleName [ProperName C.prim]) . (\\ [mn]) $
67 delete (ModuleName [ProperName C.prim]) . (\\ [mn]) $
68− imps
68+ (snd <$> imps)
69 let cppImports' = "PureScript" : cppImports
69 let cppImports' = "PureScript" : cppImports
70 cppDecls <- concat <$> mapM (bindToCpp [CppTopLevel]) decls
70 cppDecls <- concat <$> mapM (bindToCpp [CppTopLevel]) decls
71 cppDecls' <- traverse optimize cppDecls
71 cppDecls' <- traverse optimize cppDecls
@@ -109,22 +109,22 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
109 -------------------------------------------------------------------------------------------------
109 -------------------------------------------------------------------------------------------------
110 bindToCpp :: [CppValueQual] -> Bind Ann -> m [Cpp]
110 bindToCpp :: [CppValueQual] -> Bind Ann -> m [Cpp]
111 -------------------------------------------------------------------------------------------------
111 -------------------------------------------------------------------------------------------------
112− bindToCpp qs (NonRec ident val) = return <$> declToCpp qs ident val
112+ bindToCpp qs (NonRec ann ident val) = return <$> declToCpp qs (ann, ident) val
113 bindToCpp qs (Rec vals) = forM vals (uncurry $ declToCpp (CppRecursive:qs))
113 bindToCpp qs (Rec vals) = forM vals (uncurry $ declToCpp (CppRecursive:qs))
116 -- Desugar a declaration into a variable introduction or named function
116 -- Desugar a declaration into a variable introduction or named function
117 -- declaration.
117 -- declaration.
118 -------------------------------------------------------------------------------------------------
118 -------------------------------------------------------------------------------------------------
119− declToCpp :: [CppValueQual] -> Ident -> Expr Ann -> m Cpp
119+ declToCpp :: [CppValueQual] -> (Ann, Ident) -> Expr Ann -> m Cpp
120 -------------------------------------------------------------------------------------------------
120 -------------------------------------------------------------------------------------------------
121 declToCpp _ _ (Abs (_, _, _, Just IsTypeClassConstructor) _ _) =
121 declToCpp _ _ (Abs (_, _, _, Just IsTypeClassConstructor) _ _) =
122 return CppNoOp
122 return CppNoOp
124− declToCpp _ (Op _) (Var (_, _, Nothing, _) _) =
124+ declToCpp _ (_, Op _) (Var (_, _, Nothing, _) _) =
125 return CppNoOp -- skip operator aliases
125 return CppNoOp -- skip operator aliases
127− declToCpp vqs ident (Abs (_, com, ty, _) arg body) = do
127+ declToCpp vqs (_, ident) (Abs (_, com, ty, _) arg body) = do
128 fn <- if argcnt > 1 && CppTopLevel `elem` vqs
128 fn <- if argcnt > 1 && CppTopLevel `elem` vqs
130 argNames <- replicateM (argcnt - length args' - 1) freshName
130 argNames <- replicateM (argcnt - length args' - 1) freshName
@@ -180,7 +180,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
180 isIndexer (CppIndexer (CppStringLiteral _) (CppVar _)) = True
180 isIndexer (CppIndexer (CppStringLiteral _) (CppVar _)) = True
181 isIndexer _ = False
181 isIndexer _ = False
183− declToCpp _ ident (Constructor _ _ (ProperName _) []) =
183+ declToCpp _ (_, ident) (Constructor _ _ (ProperName _) []) =
185 CppFunction
185 CppFunction
186 (identToCpp ident)
186 (identToCpp ident)
@@ -190,7 +190,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
190 (asReturnBlock $
190 (asReturnBlock $
191 CppDataLiteral [CppAccessor (CppVar $ identToCpp ident) (CppVar "data")])
191 CppDataLiteral [CppAccessor (CppVar $ identToCpp ident) (CppVar "data")])
193− declToCpp _ ident (Constructor _ _ (ProperName _) fields) =
193+ declToCpp _ (_, ident) (Constructor _ _ (ProperName _) fields) =
194 return . CppNamespace "" $
194 return . CppNamespace "" $
195 [ CppFunction
195 [ CppFunction
@@ -227,7 +227,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
227 (CppBlock $ fieldLambdas fs') ]
227 (CppBlock $ fieldLambdas fs') ]
228 | otherwise = [CppReturn $ CppApp (CppVar name) (CppVar <$> fields')]
228 | otherwise = [CppReturn $ CppApp (CppVar name) (CppVar <$> fields')]
230− declToCpp qs ident e
230+ declToCpp qs (_, ident) e
231 | Just ty <- exprType e,
231 | Just ty <- exprType e,
232 CppTopLevel `elem` qs,
232 CppTopLevel `elem` qs,
233 argcnt <- countArgs ty,
233 argcnt <- countArgs ty,
@@ -262,7 +262,7 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
262 aty = Just $ CppAny [CppConst, CppRef]
262 aty = Just $ CppAny [CppConst, CppRef]
263 rty = Just $ CppAny []
263 rty = Just $ CppAny []
265− declToCpp _ ident val = do
265+ declToCpp _ (_, ident) val = do
266 val' <- valueToCpp val
266 val' <- valueToCpp val
268 CppVariableIntroduction
268 CppVariableIntroduction
@@ -750,16 +750,11 @@ moduleToCpp env (Module _ mn imps _ foreigns decls) = do
750 | mn /= mn' = CppAccessor (CppVar . identToCpp $ f a) (CppVar (moduleNameToCpp mn'))
750 | mn /= mn' = CppAccessor (CppVar . identToCpp $ f a) (CppVar (moduleNameToCpp mn'))
751 qualifiedToCpp f (Qualified _ a) = CppVar $ identToCpp (f a)
751 qualifiedToCpp f (Qualified _ a) = CppVar $ identToCpp (f a)
753− -------------------------------------------------------------------------------------------------
754− qualifiedToStr' :: (a -> Ident) -> Qualified a -> String
755− -------------------------------------------------------------------------------------------------
756− qualifiedToStr' = qualifiedToStr mn
759 -- Find a class in scope by name, retrieving its list of constraints, function names and types.
754 -- Find a class in scope by name, retrieving its list of constraints, function names and types.
761 -------------------------------------------------------------------------------------------------
756 -------------------------------------------------------------------------------------------------
762− findClass :: Qualified (ProperName ClassName) -> Maybe ([String], [T.Constraint], [(String, T.Type)])
757+ findClass :: Qualified (ProperName 'ClassName) -> Maybe ([String], [T.Constraint], [(String, T.Type)])
763 -------------------------------------------------------------------------------------------------
758 -------------------------------------------------------------------------------------------------
764 findClass name
759 findClass name
765 | Just (params, fns, constraints) <- M.lookup name (E.typeClasses env),
760 | Just (params, fns, constraints) <- M.lookup name (E.typeClasses env),