Skip to content

Commit

Permalink
Remove Rigidity
Browse files Browse the repository at this point in the history
It has been unused for some time
  • Loading branch information
alanz committed May 21, 2024
1 parent 630c4e8 commit eac9923
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
23 changes: 9 additions & 14 deletions src/Language/Haskell/GHC/ExactPrint/ExactPrint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Language.Haskell.GHC.ExactPrint.ExactPrint
, makeDeltaAst

-- * Configuration
, EPOptions(epRigidity, epAstPrint, epTokenPrint, epWhitespacePrint, epUpdateAnchors)
, EPOptions(epAstPrint, epTokenPrint, epWhitespacePrint, epUpdateAnchors)
, stringOptions
, epOptions
, deltaOptions
Expand Down Expand Up @@ -79,18 +79,16 @@ import Language.Haskell.GHC.ExactPrint.Types
exactPrint :: ExactPrint ast => ast -> String
exactPrint ast = snd $ runIdentity (runEP stringOptions (markAnnotated ast))

-- | The additional option to specify the rigidity and printing
-- configuration.
-- | The additional option to specify the printing configuration.
exactPrintWithOptions :: (ExactPrint ast, Monoid b, Monad m)
=> EPOptions m b
-> ast
-> m (ast, b)
exactPrintWithOptions r ast =
runEP r (markAnnotated ast)

-- | Transform concrete annotations into relative annotations which
-- are more useful when transforming an AST. This corresponds to the
-- earlier 'relativiseApiAnns'.
-- | Transform concrete annotations into relative annotations.
-- This should be unnecessary from GHC 9.10
makeDeltaAst :: ExactPrint ast => ast -> ast
makeDeltaAst ast = fst $ runIdentity (runEP deltaOptions (markAnnotated ast))

Expand Down Expand Up @@ -135,7 +133,6 @@ data EPOptions m a = EPOptions
epAstPrint :: forall ast . Data ast => GHC.Located ast -> a -> m a
, epTokenPrint :: String -> m a
, epWhitespacePrint :: String -> m a
, epRigidity :: Rigidity
, epUpdateAnchors :: Bool
}

Expand All @@ -144,26 +141,24 @@ epOptions ::
(forall ast . Data ast => GHC.Located ast -> a -> m a)
-> (String -> m a)
-> (String -> m a)
-> Rigidity
-> Bool
-> EPOptions m a
epOptions astPrint tokenPrint wsPrint rigidity delta = EPOptions
epOptions astPrint tokenPrint wsPrint delta = EPOptions
{
epAstPrint = astPrint
epAstPrint = astPrint -- Not used
, epWhitespacePrint = wsPrint
, epTokenPrint = tokenPrint
, epRigidity = rigidity
, epUpdateAnchors = delta
, epUpdateAnchors = delta -- Not used
}

-- | Options which can be used to print as a normal String.
stringOptions :: EPOptions Identity String
stringOptions = epOptions (\_ b -> return b) return return NormalLayout False
stringOptions = epOptions (\_ b -> return b) return return False

-- | Options which can be used to simply update the AST to be in delta
-- form, without generating output
deltaOptions :: EPOptions Identity ()
deltaOptions = epOptions (\_ _ -> return ()) (\_ -> return ()) (\_ -> return ()) NormalLayout True
deltaOptions = epOptions (\_ _ -> return ()) (\_ -> return ()) (\_ -> return ()) True

data EPWriter a = EPWriter
{ output :: !a }
Expand Down
4 changes: 0 additions & 4 deletions src/Language/Haskell/GHC/ExactPrint/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ type Pos = (Int,Int)

-- ---------------------------------------------------------------------

data Rigidity = NormalLayout | RigidLayout deriving (Eq, Ord, Show)

-- ---------------------------------------------------------------------

-- | A Haskell comment. The @AnnKeywordId@ is present if it has been converted
-- from an @AnnKeywordId@ because the annotation must be interleaved into the
-- stream and does not have a well-defined position
Expand Down

0 comments on commit eac9923

Please sign in to comment.