Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RuleCollection #891

Merged
merged 1 commit into from
May 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hindent.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ library
HIndent.Ast.Declaration.Instance.Class
HIndent.Ast.Declaration.Instance.Family.Data
HIndent.Ast.Declaration.Instance.Family.Type
HIndent.Ast.Declaration.Rule
HIndent.Ast.Declaration.Rule.Binder
HIndent.Ast.Declaration.Rule.Collection
HIndent.Ast.Declaration.Signature
HIndent.Ast.Declaration.Signature.BooleanFormula
HIndent.Ast.Declaration.Signature.Fixity
Expand Down
5 changes: 3 additions & 2 deletions src/HIndent/Ast/Declaration.hs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import HIndent.Ast.Declaration.Foreign
import HIndent.Ast.Declaration.Instance.Class
import HIndent.Ast.Declaration.Instance.Family.Data
import HIndent.Ast.Declaration.Instance.Family.Type
import HIndent.Ast.Declaration.Rule.Collection
import HIndent.Ast.Declaration.Signature
import HIndent.Ast.Declaration.Signature.StandaloneKind
import HIndent.Ast.Declaration.StandAloneDeriving
Expand Down Expand Up @@ -46,7 +47,7 @@ data Declaration
| Foreign ForeignDeclaration
| Warnings WarningCollection
| Annotation Annotation
| RuleDecl (GHC.RuleDecls GHC.GhcPs)
| RuleDecl RuleCollection
| SpliceDecl (GHC.SpliceDecl GHC.GhcPs)
| RoleAnnotDecl (GHC.RoleAnnotDecl GHC.GhcPs)

Expand Down Expand Up @@ -115,7 +116,7 @@ mkDeclaration (GHC.DefD _ x) = Default $ mkDefaultDeclaration x
mkDeclaration (GHC.ForD _ x) = Foreign $ mkForeignDeclaration x
mkDeclaration (GHC.WarningD _ x) = Warnings $ mkWarningCollection x
mkDeclaration (GHC.AnnD _ x) = Annotation $ mkAnnotation x
mkDeclaration (GHC.RuleD _ x) = RuleDecl x
mkDeclaration (GHC.RuleD _ x) = RuleDecl $ mkRuleCollection x
mkDeclaration (GHC.SpliceD _ x) = SpliceDecl x
mkDeclaration (GHC.RoleAnnotD _ x) = RoleAnnotDecl x
mkDeclaration GHC.DocD {} =
Expand Down
61 changes: 61 additions & 0 deletions src/HIndent/Ast/Declaration/Rule.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE RecordWildCards #-}

module HIndent.Ast.Declaration.Rule
( RuleDeclaration
, mkRuleDeclaration
) where

import qualified GHC.Core as GHC
import qualified GHC.Data.FastString as GHC
import HIndent.Ast.Declaration.Rule.Binder
import HIndent.Ast.NodeComments
import HIndent.Ast.WithComments
import qualified HIndent.GhcLibParserWrapper.GHC.Hs as GHC
import {-# SOURCE #-} HIndent.Pretty
import HIndent.Pretty.Combinators
import HIndent.Pretty.NodeComments

data RuleDeclaration = RuleDeclaration
{ name :: WithComments GHC.RuleName
, binders :: [WithComments RuleBinder]
, lhs :: WithComments (GHC.HsExpr GHC.GhcPs)
, rhs :: WithComments (GHC.HsExpr GHC.GhcPs)
}

instance CommentExtraction RuleDeclaration where
nodeComments RuleDeclaration {} = NodeComments [] [] []

instance Pretty RuleDeclaration where
pretty' (RuleDeclaration {..}) =
spaced
[ prettyWith name (doubleQuotes . string . GHC.unpackFS)
, prettyLhs
, string "="
, pretty rhs
]
where
prettyLhs =
if null binders
then pretty lhs
else do
string "forall "
spaced $ fmap pretty binders
dot
space
pretty lhs

mkRuleDeclaration :: GHC.RuleDecl GHC.GhcPs -> RuleDeclaration
mkRuleDeclaration rule@GHC.HsRule {..} = RuleDeclaration {..}
where
name = getName rule
binders = fmap (fmap mkRuleBinder . fromGenLocated) rd_tmvs
lhs = fromGenLocated rd_lhs
rhs = fromGenLocated rd_rhs

getName :: GHC.RuleDecl GHC.GhcPs -> WithComments GHC.RuleName
#if MIN_VERSION_ghc_lib_parser(9, 6, 1)
getName = fromGenLocated . GHC.rd_name
#else
getName = fromGenLocated . fmap snd . GHC.rd_name
#endif
31 changes: 31 additions & 0 deletions src/HIndent/Ast/Declaration/Rule/Binder.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{-# LANGUAGE RecordWildCards #-}

module HIndent.Ast.Declaration.Rule.Binder
( RuleBinder
, mkRuleBinder
) where

import HIndent.Ast.NodeComments
import HIndent.Ast.WithComments
import qualified HIndent.GhcLibParserWrapper.GHC.Hs as GHC
import {-# SOURCE #-} HIndent.Pretty
import HIndent.Pretty.Combinators
import HIndent.Pretty.NodeComments

data RuleBinder = RuleBinder
{ name :: GHC.LIdP GHC.GhcPs
, signature :: Maybe (WithComments (GHC.HsType GHC.GhcPs))
}

instance CommentExtraction RuleBinder where
nodeComments RuleBinder {} = NodeComments [] [] []

instance Pretty RuleBinder where
pretty' RuleBinder {signature = Nothing, ..} = pretty name
pretty' RuleBinder {signature = Just sig, ..} =
parens $ spaced [pretty name, string "::", pretty sig]

mkRuleBinder :: GHC.RuleBndr GHC.GhcPs -> RuleBinder
mkRuleBinder (GHC.RuleBndr _ name) = RuleBinder {signature = Nothing, ..}
mkRuleBinder (GHC.RuleBndrSig _ name GHC.HsPS {..}) =
RuleBinder {signature = Just $ fromGenLocated hsps_body, ..}
28 changes: 28 additions & 0 deletions src/HIndent/Ast/Declaration/Rule/Collection.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{-# LANGUAGE RecordWildCards #-}

module HIndent.Ast.Declaration.Rule.Collection
( RuleCollection
, mkRuleCollection
) where

import HIndent.Ast.Declaration.Rule
import HIndent.Ast.NodeComments
import HIndent.Ast.WithComments
import qualified HIndent.GhcLibParserWrapper.GHC.Hs as GHC
import {-# SOURCE #-} HIndent.Pretty
import HIndent.Pretty.Combinators
import HIndent.Pretty.NodeComments

newtype RuleCollection =
RuleCollection [WithComments RuleDeclaration]

instance CommentExtraction RuleCollection where
nodeComments RuleCollection {} = NodeComments [] [] []

instance Pretty RuleCollection where
pretty' (RuleCollection xs) =
lined $ string "{-# RULES" : fmap pretty xs ++ [string " #-}"]

mkRuleCollection :: GHC.RuleDecls GHC.GhcPs -> RuleCollection
mkRuleCollection GHC.HsRules {..} =
RuleCollection $ fmap (fmap mkRuleDeclaration . fromGenLocated) rds_rules
47 changes: 0 additions & 47 deletions src/HIndent/Pretty.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
import qualified Language.Haskell.GhclibParserEx.GHC.Hs.Expr as GHC
import Text.Show.Unicode
#if MIN_VERSION_ghc_lib_parser(9,6,1)
import qualified Data.Foldable as NonEmpty

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.2.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.2.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.4.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.4.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.6.4)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.6.4)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.2.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.2.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.6.4)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.6.4)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.4.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.4.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.2.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.2.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.4.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.4.8)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

The qualified import of `Data.Foldable' is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

The qualified import of `Data.Foldable' is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

The qualified import of `Data.Foldable' is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

The qualified import of `Data.Foldable' is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.6.4)

The qualified import of ‘Data.Foldable’ is redundant

Check warning on line 58 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.6.4)

The qualified import of ‘Data.Foldable’ is redundant
import qualified GHC.Core.DataCon as GHC
#endif
#if !MIN_VERSION_ghc_lib_parser(9,6,1)
Expand Down Expand Up @@ -545,7 +545,7 @@
prettyMatchExpr GHC.Match {m_ctxt = GHC.LambdaExpr, ..} = do
string "\\"
unless (null m_pats)
$ case GHC.unLoc $ head m_pats of

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘head’

Check warning on line 548 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘head’
GHC.LazyPat {} -> space
GHC.BangPat {} -> space
_ -> return ()
Expand Down Expand Up @@ -584,7 +584,7 @@
prettyMatchProc GHC.Match {m_ctxt = GHC.LambdaExpr, ..} = do
string "\\"
unless (null m_pats)
$ case GHC.unLoc $ head m_pats of

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘head’

Check warning on line 587 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘head’
GHC.LazyPat {} -> space
GHC.BangPat {} -> space
_ -> return ()
Expand Down Expand Up @@ -1228,7 +1228,7 @@
pretty' (GHC.DctMulti _ ts) = hvTuple $ fmap pretty ts

instance Pretty GHC.OverlapMode where
pretty' GHC.NoOverlap {} = notUsedInParsedStage

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.4.8)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.6.4)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.6.4)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.4.8)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.4.8)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

Pattern match(es) are non-exhaustive

Check warning on line 1231 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.6.4)

Pattern match(es) are non-exhaustive
pretty' GHC.Overlappable {} = string "{-# OVERLAPPABLE #-}"
pretty' GHC.Overlapping {} = string "{-# OVERLAPPING #-}"
pretty' GHC.Overlaps {} = string "{-# OVERLAPS #-}"
Expand Down Expand Up @@ -1345,8 +1345,8 @@
[] -> pure ()
[x'] -> string x'
xs -> do
string $ head xs

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-latest, nightly)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, nightly)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, nightly)

In the use of `head'

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘head’

Check warning on line 1348 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘head’
indentedWithFixedLevel 0 $ newlinePrefixed $ string <$> tail xs

Check warning on line 1349 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘tail’

Check warning on line 1349 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘tail’

Check warning on line 1349 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘tail’

Check warning on line 1349 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘tail’

Check warning on line 1349 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘tail’

Check warning on line 1349 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘tail’
pretty' (GHC.IEModuleContents _ name) =
pretty $ fmap ModuleNameWithPrefix name
pretty' GHC.IEGroup {} = docNode
Expand Down Expand Up @@ -1454,48 +1454,6 @@
pretty' GHC.HsFieldLabel {..} =
printCommentsAnd hflLabel (string . GHC.unpackFS)
#endif
instance Pretty (GHC.RuleDecls GHC.GhcPs) where
pretty' GHC.HsRules {..} =
lined $ string "{-# RULES" : fmap pretty rds_rules ++ [string " #-}"]
#if MIN_VERSION_ghc_lib_parser(9,6,1)
instance Pretty (GHC.RuleDecl GHC.GhcPs) where
pretty' GHC.HsRule {..} =
spaced
[ printCommentsAnd rd_name (doubleQuotes . string . GHC.unpackFS)
, lhs
, string "="
, pretty rd_rhs
]
where
lhs =
if null rd_tmvs
then pretty rd_lhs
else do
string "forall "
spaced $ fmap pretty rd_tmvs
dot
space
pretty rd_lhs
#else
instance Pretty (GHC.RuleDecl GHC.GhcPs) where
pretty' GHC.HsRule {..} =
spaced
[ printCommentsAnd rd_name (doubleQuotes . string . GHC.unpackFS . snd)
, lhs
, string "="
, pretty rd_rhs
]
where
lhs =
if null rd_tmvs
then pretty rd_lhs
else do
string "forall "
spaced $ fmap pretty rd_tmvs
dot
space
pretty rd_lhs
#endif
instance Pretty GHC.OccName where
pretty' = output

Expand Down Expand Up @@ -1580,7 +1538,7 @@
pretty' (GHC.HsFloatPrim _ x) = pretty x >> string "#"
pretty' GHC.HsDoublePrim {} = notUsedInParsedStage
pretty' x =
case x of

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 8.10.7)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 8.10.7)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 8.10.7)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.4.8)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.6.4)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.6.4)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.4.8)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.4.8)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

Pattern match(es) are non-exhaustive

Check warning on line 1541 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.6.4)

Pattern match(es) are non-exhaustive
GHC.HsString {} -> prettyString
GHC.HsStringPrim {} -> prettyString
where
Expand Down Expand Up @@ -1712,7 +1670,7 @@
string p |=> pretty (fmap StmtLRInsideVerticalList x)
newline
string "]"
stmtsAndPrefixes l = ("| ", head l) : fmap (", ", ) (tail l)

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘head’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘tail’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘head’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (ubuntu-latest, 9.8.1)

In the use of ‘tail’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘head’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘tail’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘head’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (windows-latest, 9.8.1)

In the use of ‘tail’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘head’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘tail’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘head’

Check warning on line 1673 in src/HIndent/Pretty.hs

View workflow job for this annotation

GitHub Actions / CI (macos-13, 9.8.1)

In the use of ‘tail’

instance Pretty DoExpression where
pretty' DoExpression {..} = do
Expand All @@ -1735,11 +1693,6 @@
pretty' LetIn {..} =
lined [string "let " |=> pretty letBinds, string " in " |=> pretty inExpr]

instance Pretty (GHC.RuleBndr GHC.GhcPs) where
pretty' (GHC.RuleBndr _ name) = pretty name
pretty' (GHC.RuleBndrSig _ name sig) =
parens $ spaced [pretty name, string "::", pretty sig]

instance Pretty GHC.HsSrcBang where
pretty' (GHC.HsSrcBang _ unpack strictness) = do
pretty unpack
Expand Down
2 changes: 0 additions & 2 deletions src/HIndent/Pretty.hs-boot
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,6 @@ instance Pretty PatInsidePatDecl

instance Pretty GHC.StringLiteral

instance Pretty (GHC.RuleDecls GHC.GhcPs)

instance Pretty (GHC.SpliceDecl GHC.GhcPs)

instance Pretty (GHC.RoleAnnotDecl GHC.GhcPs)
Expand Down
Loading