Skip to content

Commit

Permalink
Fix exports to account for constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
yav committed Jan 18, 2024
1 parent a5404e6 commit 221bf4a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Cryptol/ModuleSystem/Exports.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {} -> []
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 221bf4a

Please sign in to comment.