From 221bf4a1e7f8616372f9644ecce35c01dc8e1d53 Mon Sep 17 00:00:00 2001 From: Iavor Diatchki Date: Thu, 18 Jan 2024 12:58:37 -0800 Subject: [PATCH] Fix exports to account for constructors --- src/Cryptol/ModuleSystem/Exports.hs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Cryptol/ModuleSystem/Exports.hs b/src/Cryptol/ModuleSystem/Exports.hs index 26df487fb..b50d82bc1 100644 --- a/src/Cryptol/ModuleSystem/Exports.hs +++ b/src/Cryptol/ModuleSystem/Exports.hs @@ -25,9 +25,9 @@ exportedNames decl = ++ map exportType (names tnamesD td) DPrimType t -> [ exportType (thing . primTName <$> t) ] TDNewtype nt -> map exportType (names tnamesNT nt) ++ - map exportBind (names namesNT nt) + map exportCon (names namesNT nt) TDEnum en -> map exportType (names tnamesEnum en) - ++ map exportBind (names namesEnum en) + ++ map exportCon (names namesEnum en) Include {} -> [] DImport {} -> [] DParamDecl {} -> [] @@ -70,6 +70,10 @@ exported ns (ExportSpec mp) = Map.findWithDefault Set.empty ns mp exportBind :: Ord name => TopLevel name -> ExportSpec name exportBind = exportName NSValue +-- | Add a constructor name to the export list, if it should be exported. +exportCon :: Ord name => TopLevel name -> ExportSpec name +exportCon = exportName NSConstructor + -- | Add a type synonym name to the export list, if it should be exported. exportType :: Ord name => TopLevel name -> ExportSpec name exportType = exportName NSType @@ -84,7 +88,7 @@ isExported ns x (ExportSpec s) = -- | Check to see if a binding is exported. isExportedBind :: Ord name => name -> ExportSpec name -> Bool -isExportedBind = isExported NSValue +isExportedBind x s = isExported NSValue x s || isExported NSConstructor x s -- | Check to see if a type synonym is exported. isExportedType :: Ord name => name -> ExportSpec name -> Bool