@@ -73,6 +73,9 @@ dataGeneric = ModuleName [ ProperName "Data", ProperName "Generic" ]
7373dataMaybe :: ModuleName
7474dataMaybe = ModuleName [ ProperName "Data", ProperName "Maybe" ]
7575
76+typesProxy :: ModuleName
77+typesProxy = ModuleName [ ProperName "Type", ProperName "Proxy" ]
78+
7679deriveGeneric :: (Functor m, MonadError MultipleErrors m, MonadSupply m) => ModuleName -> [Declaration] -> ProperName -> [Type] -> m [Declaration]
7780deriveGeneric mn ds tyConNm args = do
7881 tyCon <- findTypeDecl tyConNm ds
@@ -107,7 +110,7 @@ mkSpineFunction mn (DataDeclaration _ _ _ args) = lamCase "$x" <$> mapM mkCtorCl
107110 return $ CaseAlternative [ConstructorBinder (Qualified (Just mn) ctorName) (map VarBinder idents)] (Right (caseResult idents))
108111 where
109112 caseResult idents =
110− App (prodConstructor (StringLiteral . runProperName $ ctorName))
113+ App (prodConstructor (StringLiteral . showQualified runProperName $ Qualified (Just mn) ctorName))
111114 . ArrayLiteral
112115 $ zipWith toSpineFun (map (Var . Qualified Nothing) idents) tys
113116
@@ -121,19 +124,21 @@ mkSpineFunction mn (PositionedDeclaration _ _ d) = mkSpineFunction mn d
121124mkSpineFunction _ _ = internalError "mkSpineFunction: expected DataDeclaration"
122125
123126mkSignatureFunction :: ModuleName -> Declaration -> [Type] -> Expr
124−mkSignatureFunction _ (DataDeclaration _ _ tyArgs args) classArgs = lamNull . mkSigProd $ map mkProdClause args
127+mkSignatureFunction mn (DataDeclaration _ name tyArgs args) classArgs = lamNull . mkSigProd $ map mkProdClause args
125128 where
126129 mkSigProd :: [Expr] -> Expr
127− mkSigProd = App (Constructor (Qualified (Just dataGeneric) (ProperName "SigProd"))) . ArrayLiteral
130+ mkSigProd = App (App (Constructor (Qualified (Just dataGeneric) (ProperName "SigProd")))
131+ (StringLiteral (showQualified runProperName (Qualified (Just mn) name)))
132+ ) . ArrayLiteral
128133
129134 mkSigRec :: [Expr] -> Expr
130135 mkSigRec = App (Constructor (Qualified (Just dataGeneric) (ProperName "SigRecord"))) . ArrayLiteral
131136
132137 proxy :: Type -> Type
133− proxy = TypeApp (TypeConstructor (Qualified (Just dataGeneric) (ProperName "Proxy")))
138+ proxy = TypeApp (TypeConstructor (Qualified (Just typesProxy) (ProperName "Proxy")))
134139
135140 mkProdClause :: (ProperName, [Type]) -> Expr
136− mkProdClause (ctorName, tys) = ObjectLiteral [ ("sigConstructor", StringLiteral (runProperName ctorName))
141+ mkProdClause (ctorName, tys) = ObjectLiteral [ ("sigConstructor", StringLiteral (showQualified runProperName (Qualified (Just mn) ctorName)))
137142 , ("sigValues", ArrayLiteral . map (mkProductSignature . instantiate) $ tys)
138143 ]
139144
@@ -168,7 +173,7 @@ mkFromSpineFunction mn (DataDeclaration _ _ _ args) = lamCase "$x" <$> (addCatch
168173 mkAlternative :: (ProperName, [Type]) -> m CaseAlternative
169174 mkAlternative (ctorName, tys) = do
170175 idents <- replicateM (length tys) (fmap Ident freshName)
171− return $ CaseAlternative [ prodBinder [ StringBinder (runProperName ctorName), ArrayBinder (map VarBinder idents)]]
176+ return $ CaseAlternative [ prodBinder [ StringBinder (showQualified runProperName (Qualified (Just mn) ctorName)), ArrayBinder (map VarBinder idents)]]
172177 . Right
173178 $ liftApplicative (mkJust $ Constructor (Qualified (Just mn) ctorName))
174179 (zipWith fromSpineFun (map (Var . Qualified Nothing) idents) tys)