aboutsummaryrefslogtreecommitdiff
path: root/haddock-api/src/Haddock/Utils.hs
diff options
context:
space:
mode:
authorSimon Peyton Jones <simonpj@microsoft.com>2017-11-27 13:24:01 +0000
committerSimon Peyton Jones <simonpj@microsoft.com>2017-12-07 14:39:56 +0000
commit24841386cff6fdccc11accf9daa815c2c7444d65 (patch)
treed9113a9f69d6750ae04548c44415f52327a3e2ee /haddock-api/src/Haddock/Utils.hs
parent30a25af805d1f067129b31a2ff9f0c8536768a4d (diff)
Track changes to follow Trac #14529
This tracks the refactoring of HsDecl.ConDecl.
Diffstat (limited to 'haddock-api/src/Haddock/Utils.hs')
-rw-r--r--haddock-api/src/Haddock/Utils.hs20
1 files changed, 2 insertions, 18 deletions
diff --git a/haddock-api/src/Haddock/Utils.hs b/haddock-api/src/Haddock/Utils.hs
index 84f58ab8..1993fb5d 100644
--- a/haddock-api/src/Haddock/Utils.hs
+++ b/haddock-api/src/Haddock/Utils.hs
@@ -180,33 +180,17 @@ restrictCons :: [Name] -> [LConDecl GhcRn] -> [LConDecl GhcRn]
restrictCons names decls = [ L p d | L p (Just d) <- map (fmap keep) decls ]
where
keep d | any (\n -> n `elem` names) (map unLoc $ getConNames d) =
- case getConDetails h98d of
+ case con_args d of
PrefixCon _ -> Just d
RecCon fields
| all field_avail (unL fields) -> Just d
- | otherwise -> Just (h98d { con_details = PrefixCon (field_types (map unL (unL fields))) })
+ | otherwise -> Just (d { con_args = PrefixCon (field_types (map unL (unL fields))) })
-- if we have *all* the field names available, then
-- keep the record declaration. Otherwise degrade to
-- a constructor declaration. This isn't quite right, but
-- it's the best we can do.
InfixCon _ _ -> Just d
where
- h98d = h98ConDecl d
- h98ConDecl c@ConDeclH98{} = c
- h98ConDecl c@ConDeclGADT{} = c'
- where
- (details,_res_ty,cxt,tvs) = gadtDeclDetails (con_type c)
- c' :: ConDecl GhcRn
- c' = ConDeclH98
- { con_name = head (con_names c)
- , con_qvars = Just $ HsQTvs { hsq_implicit = mempty
- , hsq_explicit = tvs
- , hsq_dependent = emptyNameSet }
- , con_cxt = Just cxt
- , con_details = details
- , con_doc = con_doc c
- }
-
field_avail :: LConDeclField GhcRn -> Bool
field_avail (L _ (ConDeclField fs _ _))
= all (\f -> selectorFieldOcc (unLoc f) `elem` names) fs