diff options
Diffstat (limited to 'haddock-api/src/Haddock/Interface')
| -rw-r--r-- | haddock-api/src/Haddock/Interface/Create.hs | 18 | ||||
| -rw-r--r-- | haddock-api/src/Haddock/Interface/Rename.hs | 26 | 
2 files changed, 27 insertions, 17 deletions
diff --git a/haddock-api/src/Haddock/Interface/Create.hs b/haddock-api/src/Haddock/Interface/Create.hs index 59809e89..ecaf1a5d 100644 --- a/haddock-api/src/Haddock/Interface/Create.hs +++ b/haddock-api/src/Haddock/Interface/Create.hs @@ -926,7 +926,7 @@ extractDecl declMap name decl              let matches = [ d' | L _ d'@(DataFamInstDecl (HsIB { hsib_body = d }))                                     <- insts                                   -- , L _ ConDecl { con_details = RecCon rec } <- dd_cons (feqn_rhs d) -                               , RecCon rec <- map (getConArgs . unLoc) (dd_cons (feqn_rhs d)) +                               , Just rec <- map (getRecConArgs_maybe . unLoc) (dd_cons (feqn_rhs d))                                 , ConDeclField { cd_fld_names = ns } <- map unLoc (unLoc rec)                                 , L _ n <- ns                                 , extFieldOcc n == name @@ -949,10 +949,14 @@ extractPatternSyn nm t tvs cons =    extract :: ConDecl GhcRn -> Sig GhcRn    extract con =      let args = -          case getConArgs con of -            PrefixCon args' -> (map hsScaledThing args') -            RecCon (L _ fields) -> cd_fld_type . unLoc <$> fields -            InfixCon arg1 arg2 -> map hsScaledThing [arg1, arg2] +          case con of +            ConDeclH98 { con_args = con_args' } -> case con_args' of +              PrefixCon args' -> map hsScaledThing args' +              RecCon (L _ fields) -> cd_fld_type . unLoc <$> fields +              InfixCon arg1 arg2 -> map hsScaledThing [arg1, arg2] +            ConDeclGADT { con_g_args = con_args' } -> case con_args' of +              PrefixConGADT args' -> map hsScaledThing args' +              RecConGADT (L _ fields) -> cd_fld_type . unLoc <$> fields          typ = longArrow args (data_ty con)          typ' =            case con of @@ -977,8 +981,8 @@ extractRecSel :: Name -> Name -> [LHsTypeArg GhcRn] -> [LConDecl GhcRn]  extractRecSel _ _ _ [] = error "extractRecSel: selector not found"  extractRecSel nm t tvs (L _ con : rest) = -  case getConArgs con of -    RecCon (L _ fields) | ((l,L _ (ConDeclField _ _nn ty _)) : _) <- matching_fields fields -> +  case getRecConArgs_maybe con of +    Just (L _ fields) | ((l,L _ (ConDeclField _ _nn ty _)) : _) <- matching_fields fields ->        L l (TypeSig noExtField [noLoc nm] (mkEmptySigWcType (noLoc (HsFunTy noExtField (HsUnrestrictedArrow NormalSyntax) data_ty (getBangType ty)))))      _ -> extractRecSel nm t tvs rest   where diff --git a/haddock-api/src/Haddock/Interface/Rename.hs b/haddock-api/src/Haddock/Interface/Rename.hs index 67439383..e7d19dfe 100644 --- a/haddock-api/src/Haddock/Interface/Rename.hs +++ b/haddock-api/src/Haddock/Interface/Rename.hs @@ -479,7 +479,7 @@ renameCon decl@(ConDeclH98 { con_name = lname, con_ex_tvs = ltyvars        lname'    <- renameL lname        ltyvars'  <- mapM renameLTyVarBndr ltyvars        lcontext' <- traverse renameLContext lcontext -      details'  <- renameDetails details +      details'  <- renameH98Details details        mbldoc'   <- mapM renameLDocHsSyn mbldoc        return (decl { con_ext = noExtField, con_name = lname', con_ex_tvs = ltyvars'                     , con_mb_cxt = lcontext' @@ -487,18 +487,18 @@ renameCon decl@(ConDeclH98 { con_name = lname, con_ex_tvs = ltyvars                     , con_args = details', con_doc = mbldoc' })  renameCon ConDeclGADT { con_names = lnames, con_qvars = ltyvars -                            , con_mb_cxt = lcontext, con_args = details +                            , con_mb_cxt = lcontext, con_g_args = details                              , con_res_ty = res_ty, con_forall = forall                              , con_doc = mbldoc } = do        lnames'   <- mapM renameL lnames        ltyvars'  <- mapM renameLTyVarBndr ltyvars        lcontext' <- traverse renameLContext lcontext -      details'  <- renameDetails details +      details'  <- renameGADTDetails details        res_ty'   <- renameLType res_ty        mbldoc'   <- mapM renameLDocHsSyn mbldoc        return (ConDeclGADT                     { con_g_ext = noExtField, con_names = lnames', con_qvars = ltyvars' -                   , con_mb_cxt = lcontext', con_args = details' +                   , con_mb_cxt = lcontext', con_g_args = details'                     , con_res_ty = res_ty', con_doc = mbldoc'                     , con_forall = forall}) -- Remove when #18311 is fixed @@ -506,18 +506,24 @@ renameHsScaled :: HsScaled GhcRn (LHsType GhcRn)                 -> RnM (HsScaled DocNameI (LHsType DocNameI))  renameHsScaled (HsScaled w ty) = HsScaled <$> renameArrow w <*> renameLType ty -renameDetails :: HsConDeclDetails GhcRn -> RnM (HsConDeclDetails DocNameI) -renameDetails (RecCon (L l fields)) = do +renameH98Details :: HsConDeclH98Details GhcRn +                 -> RnM (HsConDeclH98Details DocNameI) +renameH98Details (RecCon (L l fields)) = do    fields' <- mapM renameConDeclFieldField fields    return (RecCon (L l fields')) -                               -- This causes an assertion failure ---renameDetails (PrefixCon ps) = -- return . PrefixCon =<< mapM (_renameLType) ps -renameDetails (PrefixCon ps) = PrefixCon <$> mapM renameHsScaled ps -renameDetails (InfixCon a b) = do +renameH98Details (PrefixCon ps) = PrefixCon <$> mapM renameHsScaled ps +renameH98Details (InfixCon a b) = do    a' <- renameHsScaled a    b' <- renameHsScaled b    return (InfixCon a' b') +renameGADTDetails :: HsConDeclGADTDetails GhcRn +                  -> RnM (HsConDeclGADTDetails DocNameI) +renameGADTDetails (RecConGADT (L l fields)) = do +  fields' <- mapM renameConDeclFieldField fields +  return (RecConGADT (L l fields')) +renameGADTDetails (PrefixConGADT ps) = PrefixConGADT <$> mapM renameHsScaled ps +  renameConDeclFieldField :: LConDeclField GhcRn -> RnM (LConDeclField DocNameI)  renameConDeclFieldField (L l (ConDeclField _ names t doc)) = do    names' <- mapM renameLFieldOcc names  | 
