Remove redundant pattern matches
parent
c361ba545d
commit
0c33d9a6fa
|
@ -40,7 +40,6 @@ layoutDataDecl
|
||||||
-> LHsQTyVars GhcPs
|
-> LHsQTyVars GhcPs
|
||||||
-> HsDataDefn GhcPs
|
-> HsDataDefn GhcPs
|
||||||
-> ToBriDocM BriDocNumbered
|
-> ToBriDocM BriDocNumbered
|
||||||
layoutDataDecl _ _ (XLHsQTyVars ext) _ = absurdExt ext
|
|
||||||
layoutDataDecl ltycl name (HsQTvs _ bndrs) defn = case defn of
|
layoutDataDecl ltycl name (HsQTvs _ bndrs) defn = case defn of
|
||||||
-- newtype MyType a b = MyType ..
|
-- newtype MyType a b = MyType ..
|
||||||
HsDataDefn _ext NewType (L _ []) _ctype Nothing [cons] mDerivs -> case cons of
|
HsDataDefn _ext NewType (L _ []) _ctype Nothing [cons] mDerivs -> case cons of
|
||||||
|
@ -245,7 +244,6 @@ createBndrDoc bs = do
|
||||||
(L _ (KindedTyVar _ _ext lrdrName kind)) -> do
|
(L _ (KindedTyVar _ _ext lrdrName kind)) -> do
|
||||||
d <- docSharedWrapper layoutType kind
|
d <- docSharedWrapper layoutType kind
|
||||||
return $ (lrdrNameToText lrdrName, Just $ d)
|
return $ (lrdrNameToText lrdrName, Just $ d)
|
||||||
(L _ (XTyVarBndr ext)) -> absurdExt ext
|
|
||||||
docSeq
|
docSeq
|
||||||
$ List.intersperse docSeparator
|
$ List.intersperse docSeparator
|
||||||
$ tyVarDocs
|
$ tyVarDocs
|
||||||
|
@ -275,7 +273,6 @@ createDerivingPar derivs mainDoc = do
|
||||||
<$> types
|
<$> types
|
||||||
|
|
||||||
derivingClauseDoc :: LHsDerivingClause GhcPs -> ToBriDocM BriDocNumbered
|
derivingClauseDoc :: LHsDerivingClause GhcPs -> ToBriDocM BriDocNumbered
|
||||||
derivingClauseDoc (L _ (XHsDerivingClause ext)) = absurdExt ext
|
|
||||||
derivingClauseDoc (L _ (HsDerivingClause _ext mStrategy types)) = case types of
|
derivingClauseDoc (L _ (HsDerivingClause _ext mStrategy types)) = case types of
|
||||||
(L _ []) -> docSeq []
|
(L _ []) -> docSeq []
|
||||||
(L _ ts) ->
|
(L _ ts) ->
|
||||||
|
@ -295,7 +292,6 @@ derivingClauseDoc (L _ (HsDerivingClause _ext mStrategy types)) = case types of
|
||||||
$ List.intersperse docCommaSep
|
$ List.intersperse docCommaSep
|
||||||
$ ts <&> \case
|
$ ts <&> \case
|
||||||
HsIB _ t -> layoutType t
|
HsIB _ t -> layoutType t
|
||||||
XHsImplicitBndrs x -> absurdExt x
|
|
||||||
, whenMoreThan1Type ")"
|
, whenMoreThan1Type ")"
|
||||||
, rhsStrategy
|
, rhsStrategy
|
||||||
]
|
]
|
||||||
|
@ -312,7 +308,6 @@ derivingClauseDoc (L _ (HsDerivingClause _ext mStrategy types)) = case types of
|
||||||
, docSeparator
|
, docSeparator
|
||||||
, layoutType t
|
, layoutType t
|
||||||
]
|
]
|
||||||
XHsImplicitBndrs ext -> absurdExt ext
|
|
||||||
)
|
)
|
||||||
|
|
||||||
docDeriving :: ToBriDocM BriDocNumbered
|
docDeriving :: ToBriDocM BriDocNumbered
|
||||||
|
@ -432,7 +427,6 @@ createDetailsDoc consNameStr details = case details of
|
||||||
-> [(ToBriDocM BriDocNumbered, ToBriDocM BriDocNumbered)]
|
-> [(ToBriDocM BriDocNumbered, ToBriDocM BriDocNumbered)]
|
||||||
mkFieldDocs = fmap $ \lField -> case lField of
|
mkFieldDocs = fmap $ \lField -> case lField of
|
||||||
L _ (ConDeclField _ext names t _) -> createNamesAndTypeDoc lField names t
|
L _ (ConDeclField _ext names t _) -> createNamesAndTypeDoc lField names t
|
||||||
L _ (XConDeclField x) -> absurdExt x
|
|
||||||
|
|
||||||
createForallDoc :: [LHsTyVarBndr flag GhcPs] -> Maybe (ToBriDocM BriDocNumbered)
|
createForallDoc :: [LHsTyVarBndr flag GhcPs] -> Maybe (ToBriDocM BriDocNumbered)
|
||||||
createForallDoc [] = Nothing
|
createForallDoc [] = Nothing
|
||||||
|
@ -451,7 +445,6 @@ createNamesAndTypeDoc lField names t =
|
||||||
$ List.intersperse docCommaSep
|
$ List.intersperse docCommaSep
|
||||||
$ names
|
$ names
|
||||||
<&> \case
|
<&> \case
|
||||||
L _ (XFieldOcc x) -> absurdExt x
|
|
||||||
L _ (FieldOcc _ fieldName) ->
|
L _ (FieldOcc _ fieldName) ->
|
||||||
docLit =<< lrdrNameToTextAnn fieldName
|
docLit =<< lrdrNameToTextAnn fieldName
|
||||||
]
|
]
|
||||||
|
|
|
@ -90,6 +90,7 @@ layoutSig lsig@(L _loc sig) = case sig of
|
||||||
AlwaysActive -> ""
|
AlwaysActive -> ""
|
||||||
ActiveBefore _ i -> "[~" ++ show i ++ "] "
|
ActiveBefore _ i -> "[~" ++ show i ++ "] "
|
||||||
ActiveAfter _ i -> "[" ++ show i ++ "] "
|
ActiveAfter _ i -> "[" ++ show i ++ "] "
|
||||||
|
FinalActive -> error "brittany internal error: FinalActive"
|
||||||
let conlikeStr = case conlike of
|
let conlikeStr = case conlike of
|
||||||
FunLike -> ""
|
FunLike -> ""
|
||||||
ConLike -> "CONLIKE "
|
ConLike -> "CONLIKE "
|
||||||
|
@ -190,7 +191,6 @@ layoutBind lbind@(L _ bind) = case bind of
|
||||||
_ -> Right <$> unknownNodeError "" lbind
|
_ -> Right <$> unknownNodeError "" lbind
|
||||||
layoutIPBind :: ToBriDoc IPBind
|
layoutIPBind :: ToBriDoc IPBind
|
||||||
layoutIPBind lipbind@(L _ bind) = case bind of
|
layoutIPBind lipbind@(L _ bind) = case bind of
|
||||||
XIPBind{} -> unknownNodeError "XIPBind" lipbind
|
|
||||||
IPBind _ (Right _) _ -> error "brittany internal error: IPBind Right"
|
IPBind _ (Right _) _ -> error "brittany internal error: IPBind Right"
|
||||||
IPBind _ (Left (L _ (HsIPName name))) expr -> do
|
IPBind _ (Left (L _ (HsIPName name))) expr -> do
|
||||||
ipName <- docLit $ Text.pack $ '?' : FastString.unpackFS name
|
ipName <- docLit $ Text.pack $ '?' : FastString.unpackFS name
|
||||||
|
@ -225,9 +225,6 @@ layoutLocalBinds lbinds@(L _ binds) = case binds of
|
||||||
return $ Just $ docs
|
return $ Just $ docs
|
||||||
-- x@(HsValBinds (ValBindsOut _binds _lsigs)) ->
|
-- x@(HsValBinds (ValBindsOut _binds _lsigs)) ->
|
||||||
HsValBinds _ (XValBindsLR{}) -> error "brittany internal error: XValBindsLR"
|
HsValBinds _ (XValBindsLR{}) -> error "brittany internal error: XValBindsLR"
|
||||||
XHsLocalBindsLR{} -> error "brittany internal error: XHsLocalBindsLR"
|
|
||||||
x@(HsIPBinds _ XHsIPBinds{}) ->
|
|
||||||
Just . (: []) <$> unknownNodeError "XHsIPBinds" (L noSrcSpan x)
|
|
||||||
HsIPBinds _ (IPBinds _ bb) ->
|
HsIPBinds _ (IPBinds _ bb) ->
|
||||||
Just <$> mapM layoutIPBind bb
|
Just <$> mapM layoutIPBind bb
|
||||||
EmptyLocalBinds{} -> return $ Nothing
|
EmptyLocalBinds{} -> return $ Nothing
|
||||||
|
@ -241,7 +238,6 @@ layoutGrhs lgrhs@(L _ (GRHS _ guards body)) = do
|
||||||
guardDocs <- docWrapNode lgrhs $ layoutStmt `mapM` guards
|
guardDocs <- docWrapNode lgrhs $ layoutStmt `mapM` guards
|
||||||
bodyDoc <- layoutExpr body
|
bodyDoc <- layoutExpr body
|
||||||
return (guardDocs, bodyDoc, body)
|
return (guardDocs, bodyDoc, body)
|
||||||
layoutGrhs (L _ (XGRHS{})) = error "brittany internal error: XGRHS"
|
|
||||||
|
|
||||||
layoutPatternBind
|
layoutPatternBind
|
||||||
:: Maybe Text
|
:: Maybe Text
|
||||||
|
@ -766,7 +762,6 @@ layoutSynDecl isInfix wrapNodeRest name vars typ = do
|
||||||
layoutTyVarBndr :: Bool -> ToBriDoc (HsTyVarBndr ())
|
layoutTyVarBndr :: Bool -> ToBriDoc (HsTyVarBndr ())
|
||||||
layoutTyVarBndr needsSep lbndr@(L _ bndr) = do
|
layoutTyVarBndr needsSep lbndr@(L _ bndr) = do
|
||||||
docWrapNodePrior lbndr $ case bndr of
|
docWrapNodePrior lbndr $ case bndr of
|
||||||
XTyVarBndr{} -> error "brittany internal error: XTyVarBndr"
|
|
||||||
UserTyVar _ _ name -> do
|
UserTyVar _ _ name -> do
|
||||||
nameStr <- lrdrNameToTextAnn name
|
nameStr <- lrdrNameToTextAnn name
|
||||||
docSeq $ [docSeparator | needsSep] ++ [docLit nameStr]
|
docSeq $ [docSeparator | needsSep] ++ [docLit nameStr]
|
||||||
|
|
|
@ -127,8 +127,6 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
]
|
]
|
||||||
HsLam{} ->
|
HsLam{} ->
|
||||||
unknownNodeError "HsLam too complex" lexpr
|
unknownNodeError "HsLam too complex" lexpr
|
||||||
HsLamCase _ XMatchGroup{} ->
|
|
||||||
error "brittany internal error: HsLamCase XMatchGroup"
|
|
||||||
HsLamCase _ (MG _ (L _ []) _) -> do
|
HsLamCase _ (MG _ (L _ []) _) -> do
|
||||||
docSetParSpacing $ docAddBaseY BrIndentRegular $
|
docSetParSpacing $ docAddBaseY BrIndentRegular $
|
||||||
(docLit $ Text.pack "\\case {}")
|
(docLit $ Text.pack "\\case {}")
|
||||||
|
@ -230,8 +228,6 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
expDoc1
|
expDoc1
|
||||||
expDoc2
|
expDoc2
|
||||||
]
|
]
|
||||||
HsAppType _ _ XHsWildCardBndrs{} ->
|
|
||||||
error "brittany internal error: HsAppType XHsWildCardBndrs"
|
|
||||||
HsAppType _ exp1 (HsWC _ ty1) -> do
|
HsAppType _ exp1 (HsWC _ ty1) -> do
|
||||||
t <- docSharedWrapper layoutType ty1
|
t <- docSharedWrapper layoutType ty1
|
||||||
e <- docSharedWrapper layoutExpr exp1
|
e <- docSharedWrapper layoutExpr exp1
|
||||||
|
@ -392,7 +388,6 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
let argExprs = args <&> \arg -> case arg of
|
let argExprs = args <&> \arg -> case arg of
|
||||||
(L _ (Present _ e)) -> (arg, Just e);
|
(L _ (Present _ e)) -> (arg, Just e);
|
||||||
(L _ (Missing NoExtField)) -> (arg, Nothing)
|
(L _ (Missing NoExtField)) -> (arg, Nothing)
|
||||||
(L _ XTupArg{}) -> error "brittany internal error: XTupArg"
|
|
||||||
argDocs <- forM argExprs
|
argDocs <- forM argExprs
|
||||||
$ docSharedWrapper
|
$ docSharedWrapper
|
||||||
$ \(arg, exprM) -> docWrapNode arg $ maybe docEmpty layoutExpr exprM
|
$ \(arg, exprM) -> docWrapNode arg $ maybe docEmpty layoutExpr exprM
|
||||||
|
@ -437,8 +432,6 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
lineN = docCols ColTuples [docCommaSep, docNodeAnnKW lexpr (Just AnnOpenP) eN]
|
lineN = docCols ColTuples [docCommaSep, docNodeAnnKW lexpr (Just AnnOpenP) eN]
|
||||||
end = closeLit
|
end = closeLit
|
||||||
in docSetBaseY $ docLines $ [start] ++ linesM ++ [lineN, end]
|
in docSetBaseY $ docLines $ [start] ++ linesM ++ [lineN, end]
|
||||||
HsCase _ _ XMatchGroup{} ->
|
|
||||||
error "brittany internal error: HsCase XMatchGroup"
|
|
||||||
HsCase _ cExp (MG _ (L _ []) _) -> do
|
HsCase _ cExp (MG _ (L _ []) _) -> do
|
||||||
cExpDoc <- docSharedWrapper layoutExpr cExp
|
cExpDoc <- docSharedWrapper layoutExpr cExp
|
||||||
docAlt
|
docAlt
|
||||||
|
@ -834,13 +827,7 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
return $ case ambName of
|
return $ case ambName of
|
||||||
Unambiguous _ n -> (lfield, lrdrNameToText n, rFExpDoc)
|
Unambiguous _ n -> (lfield, lrdrNameToText n, rFExpDoc)
|
||||||
Ambiguous _ n -> (lfield, lrdrNameToText n, rFExpDoc)
|
Ambiguous _ n -> (lfield, lrdrNameToText n, rFExpDoc)
|
||||||
XAmbiguousFieldOcc{} ->
|
|
||||||
error "brittany internal error: XAmbiguousFieldOcc"
|
|
||||||
recordExpression False indentPolicy lexpr rExprDoc rFs
|
recordExpression False indentPolicy lexpr rExprDoc rFs
|
||||||
ExprWithTySig _ _ (HsWC _ XHsImplicitBndrs{}) ->
|
|
||||||
error "brittany internal error: ExprWithTySig HsWC XHsImplicitBndrs"
|
|
||||||
ExprWithTySig _ _ XHsWildCardBndrs{} ->
|
|
||||||
error "brittany internal error: ExprWithTySig XHsWildCardBndrs"
|
|
||||||
ExprWithTySig _ exp1 (HsWC _ (HsIB _ typ1)) -> do
|
ExprWithTySig _ exp1 (HsWC _ (HsIB _ typ1)) -> do
|
||||||
expDoc <- docSharedWrapper layoutExpr exp1
|
expDoc <- docSharedWrapper layoutExpr exp1
|
||||||
typDoc <- docSharedWrapper layoutType typ1
|
typDoc <- docSharedWrapper layoutType typ1
|
||||||
|
@ -931,7 +918,9 @@ layoutExpr lexpr@(L _ expr) = do
|
||||||
ExplicitSum{} -> do
|
ExplicitSum{} -> do
|
||||||
-- TODO
|
-- TODO
|
||||||
briDocByExactInlineOnly "ExplicitSum{}" lexpr
|
briDocByExactInlineOnly "ExplicitSum{}" lexpr
|
||||||
XExpr{} -> error "brittany internal error: XExpr"
|
HsPragE{} -> do
|
||||||
|
-- TODO
|
||||||
|
briDocByExactInlineOnly "HsPragE{}" lexpr
|
||||||
|
|
||||||
recordExpression
|
recordExpression
|
||||||
:: (Data.Data.Data lExpr, Data.Data.Data name)
|
:: (Data.Data.Data lExpr, Data.Data.Data name)
|
||||||
|
|
|
@ -217,7 +217,6 @@ lieToText = \case
|
||||||
L _ (IEGroup _ _ _ ) -> Text.pack "@IEGroup"
|
L _ (IEGroup _ _ _ ) -> Text.pack "@IEGroup"
|
||||||
L _ (IEDoc _ _ ) -> Text.pack "@IEDoc"
|
L _ (IEDoc _ _ ) -> Text.pack "@IEDoc"
|
||||||
L _ (IEDocNamed _ _ ) -> Text.pack "@IEDocNamed"
|
L _ (IEDocNamed _ _ ) -> Text.pack "@IEDocNamed"
|
||||||
L _ (XIE _ ) -> Text.pack "@XIE"
|
|
||||||
where
|
where
|
||||||
moduleNameToText :: Located ModuleName -> Text
|
moduleNameToText :: Located ModuleName -> Text
|
||||||
moduleNameToText (L _ name) = Text.pack ("@IEModuleContents" ++ moduleNameString name)
|
moduleNameToText (L _ name) = Text.pack ("@IEModuleContents" ++ moduleNameString name)
|
||||||
|
|
|
@ -633,7 +633,6 @@ layoutTyVarBndrs = mapM $ \case
|
||||||
(L _ (KindedTyVar _ _ lrdrName kind)) -> do
|
(L _ (KindedTyVar _ _ lrdrName kind)) -> do
|
||||||
d <- docSharedWrapper layoutType kind
|
d <- docSharedWrapper layoutType kind
|
||||||
return $ (lrdrNameToText lrdrName, Just $ d)
|
return $ (lrdrNameToText lrdrName, Just $ d)
|
||||||
(L _ (XTyVarBndr{})) -> error "brittany internal error: XTyVarBndr"
|
|
||||||
|
|
||||||
-- there is no specific reason this returns a list instead of a single
|
-- there is no specific reason this returns a list instead of a single
|
||||||
-- BriDoc node.
|
-- BriDoc node.
|
||||||
|
|
Loading…
Reference in New Issue