packages feed

hindent 4.3.12 → 4.4.0

raw patch · 3 files changed

+37/−25 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- HIndent: prettyPrint :: ParseMode -> Style -> (forall s. Printer s ()) -> Builder
+ HIndent: prettyPrint :: ParseMode -> Style -> Module SrcSpanInfo -> [Comment] -> Either a Builder

Files

hindent.cabal view
@@ -1,5 +1,5 @@ name:                hindent-version:             4.3.12+version:             4.4.0 synopsis:            Extensible Haskell pretty printer description:         Extensible Haskell pretty printer. Both a library and an executable.                      .
src/HIndent.hs view
@@ -46,34 +46,46 @@ -- | Format the given source. reformat :: Style -> Maybe [Extension] -> Text -> Either String Builder reformat style mexts x =-  case parseModuleWithComments mode+  case parseModuleWithComments mode'                                (T.unpack x) of     ParseOk (m,comments) ->-      let (cs,ast) =-            annotateComments (fromMaybe m $ applyFixities baseFixities m) comments-      in Right (prettyPrint-                  mode-                  style-                  -- For the time being, assume that all "free-floating" comments come at the beginning.-                  -- If they were not at the beginning, they would be after some ast node.-                  -- Thus, print them before going for the ast.-                  (do mapM_ (printComment Nothing) (reverse cs)-                      pretty ast))+      prettyPrint mode' style m comments     ParseFailed _ e -> Left e-  where mode = (case mexts of-                  Just exts -> parseMode {extensions = exts}-                  Nothing -> parseMode)+  where mode' =+          (case mexts of+             Just exts ->+               parseMode {extensions = exts}+             Nothing -> parseMode) +-- | Print the module.+prettyPrint :: ParseMode+            -> Style+            -> Module SrcSpanInfo+            -> [Comment]+            -> Either a Builder+prettyPrint mode' style m comments =+  let (cs,ast) =+        annotateComments (fromMaybe m (applyFixities baseFixities m))+                         comments+  in Right (runPrinterStyle+              mode'+              style+              -- For the time being, assume that all "free-floating" comments come at the beginning.+              -- If they were not at the beginning, they would be after some ast node.+              -- Thus, print them before going for the ast.+              (do mapM_ (printComment Nothing)+                        (reverse cs)+                  pretty ast))+ -- | Pretty print the given printable thing.-prettyPrint :: ParseMode -> Style -> (forall s. Printer s ()) -> Builder-prettyPrint mode style m =-  case style of-    Style _name _author _desc st extenders config ->-      maybe (error "Printer failed with mzero call.")-            psOutput-            (runIdentity-               (runMaybeT (execStateT (runPrinter m)-                                      (PrintState 0 mempty False 0 1 st extenders config False False mode))))+runPrinterStyle :: ParseMode -> Style -> (forall s. Printer s ()) -> Builder+runPrinterStyle mode' (Style _name _author _desc st extenders config) m =+  maybe (error "Printer failed with mzero call.")+        psOutput+        (runIdentity+           (runMaybeT (execStateT+                         (runPrinter m)+                         (PrintState 0 mempty False 0 1 st extenders config False False mode'))))  -- | Parse mode, includes all extensions, doesn't assume any fixities. parseMode :: ParseMode
src/HIndent/Types.hs view
@@ -53,7 +53,7 @@              }  instance Eq (PrintState s) where-  PrintState ilevel out newline col line _ _ _ eolc inc pm == PrintState ilevel' out' newline' col' line' _ _ _ eolc' inc' pm' =+  PrintState ilevel out newline col line _ _ _ eolc inc _ == PrintState ilevel' out' newline' col' line' _ _ _ eolc' inc' _ =     (ilevel,out,newline,col,line,eolc, inc) == (ilevel',out',newline',col',line',eolc', inc')  -- | A printer extender. Takes as argument the user state that the