Commit 857847a6 authored by simonpj@microsoft.com's avatar simonpj@microsoft.com
Browse files

Rename conDeclsNames to hsConDeclsNames, and export it

parent e598b8f9
...@@ -42,7 +42,7 @@ module HsDecls ( ...@@ -42,7 +42,7 @@ module HsDecls (
CImportSpec(..), FoType(..), CImportSpec(..), FoType(..),
-- ** Data-constructor declarations -- ** Data-constructor declarations
ConDecl(..), LConDecl, ResType(..), ConDeclField(..), ConDecl(..), LConDecl, ResType(..), ConDeclField(..),
HsConDeclDetails, hsConDeclArgTys, HsConDeclDetails, hsConDeclArgTys, hsConDeclsNames,
-- ** Document comments -- ** Document comments
DocDecl(..), LDocDecl, docDeclDoc, DocDecl(..), LDocDecl, docDeclDoc,
-- ** Deprecations -- ** Deprecations
...@@ -548,7 +548,7 @@ tyClDeclNames (ClassDecl {tcdLName = cls_name, tcdSigs = sigs, tcdATs = ats}) ...@@ -548,7 +548,7 @@ tyClDeclNames (ClassDecl {tcdLName = cls_name, tcdSigs = sigs, tcdATs = ats})
concatMap (tyClDeclNames . unLoc) ats ++ [n | L _ (TypeSig n _) <- sigs] concatMap (tyClDeclNames . unLoc) ats ++ [n | L _ (TypeSig n _) <- sigs]
tyClDeclNames (TyData {tcdLName = tc_name, tcdCons = cons}) tyClDeclNames (TyData {tcdLName = tc_name, tcdCons = cons})
= tc_name : conDeclsNames (map unLoc cons) = tc_name : hsConDeclsNames cons
tyClDeclTyVars :: TyClDecl name -> [LHsTyVarBndr name] tyClDeclTyVars :: TyClDecl name -> [LHsTyVarBndr name]
tyClDeclTyVars (TyFamily {tcdTyVars = tvs}) = tvs tyClDeclTyVars (TyFamily {tcdTyVars = tvs}) = tvs
...@@ -741,21 +741,21 @@ data ResType name ...@@ -741,21 +741,21 @@ data ResType name
\end{code} \end{code}
\begin{code} \begin{code}
conDeclsNames :: (Eq name) => [ConDecl name] -> [Located name] hsConDeclsNames :: (Eq name) => [LConDecl name] -> [Located name]
-- See tyClDeclNames for what this does -- See tyClDeclNames for what this does
-- The function is boringly complicated because of the records -- The function is boringly complicated because of the records
-- And since we only have equality, we have to be a little careful -- And since we only have equality, we have to be a little careful
conDeclsNames cons hsConDeclsNames cons
= snd (foldl do_one ([], []) cons) = snd (foldl do_one ([], []) cons)
where where
do_one (flds_seen, acc) (ConDecl { con_name = lname, con_details = RecCon flds }) do_one (flds_seen, acc) (L _ (ConDecl { con_name = lname, con_details = RecCon flds }))
= (map unLoc new_flds ++ flds_seen, lname : new_flds ++ acc) = (map unLoc new_flds ++ flds_seen, lname : new_flds ++ acc)
where where
new_flds = filterOut (\f -> unLoc f `elem` flds_seen) new_flds = filterOut (\f -> unLoc f `elem` flds_seen)
(map cd_fld_name flds) (map cd_fld_name flds)
do_one (flds_seen, acc) c do_one (flds_seen, acc) (L _ (ConDecl { con_name = lname }))
= (flds_seen, (con_name c):acc) = (flds_seen, lname:acc)
\end{code} \end{code}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment