haskell-tools-prettyprint 1.0.1.1 → 1.1.0.0
raw patch · 9 files changed
+31/−17 lines, 9 filesdep ~basedep ~ghcdep ~haskell-tools-ast
Dependency ranges changed: base, ghc, haskell-tools-ast
Files
- Language/Haskell/Tools/PrettyPrint.hs +3/−3
- Language/Haskell/Tools/PrettyPrint/Prepare.hs +1/−1
- Language/Haskell/Tools/PrettyPrint/Prepare/PlaceComments.hs +3/−1
- Language/Haskell/Tools/PrettyPrint/Prepare/RangeTemplate.hs +4/−1
- Language/Haskell/Tools/PrettyPrint/Prepare/RangeToRangeTemplate.hs +1/−1
- Language/Haskell/Tools/PrettyPrint/Prepare/SourceTemplate.hs +6/−1
- Language/Haskell/Tools/PrettyPrint/Prepare/SourceTemplateHelpers.hs +6/−4
- Language/Haskell/Tools/PrettyPrint/RoseTree.hs +3/−1
- haskell-tools-prettyprint.cabal +4/−4
Language/Haskell/Tools/PrettyPrint.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE FlexibleContexts, RecordPuns, UndecidableInstances #-} +{-# LANGUAGE NamedFieldPuns #-} -- | Pretty printing the AST @@ -40,10 +40,10 @@ printTemplateElems (ChildElem : rest) (child : children) = printRose' parent child >+< printTemplateElems rest children printTemplateElems [] [] = return empty printTemplateElems _ [] - = pprProblem $ "More child elem in template than actual children in: " + = pprProblem $ "More child elem in template than actual children in: " ++ shortShowSpanWithFile (srcLocSpan $ RealSrcLoc parent) printTemplateElems [] _ - = pprProblem $ "Not all children are used to pretty printing in: " + = pprProblem $ "Not all children are used to pretty printing in: " ++ shortShowSpanWithFile (srcLocSpan $ RealSrcLoc parent) min = minInd `max` getPosByRelative parent relInd
Language/Haskell/Tools/PrettyPrint/Prepare.hs view
@@ -4,7 +4,7 @@ -- comment handling , placeComments, getNormalComments, getPragmaComments -- generating source templates - , child, opt, list, after, followedBy, relativeIndented, minimumIndented, separatedBy, indented, (<>) + , child, opt, list, after, followedBy, relativeIndented, minimumIndented, separatedBy, indented -- references on source templates , sourceTemplateNodeRange, sourceTemplateNodeElems , sourceTemplateListRange, srcTmpListBefore, srcTmpListAfter, srcTmpDefaultSeparator, srcTmpIndented, srcTmpSeparators
Language/Haskell/Tools/PrettyPrint/Prepare/PlaceComments.hs view
@@ -1,4 +1,6 @@-{-# LANGUAGE FlexibleContexts, LambdaCase, ScopedTypeVariables #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE ScopedTypeVariables #-} -- | This transformation expands nodes to contain the comments that should be attached to them. After this, a -- normalizing transformation should be performed that expands parents to contain their children.
Language/Haskell/Tools/PrettyPrint/Prepare/RangeTemplate.hs view
@@ -1,4 +1,7 @@-{-# LANGUAGE DeriveDataTypeable, FlexibleInstances, RecordWildCards, TypeFamilies #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TypeFamilies #-} -- | The range template is an intermediate annotation level, where the children nodes of the tree -- had been cut from the parent nodes, but the annotations still contain ranges instead of text.
Language/Haskell/Tools/PrettyPrint/Prepare/RangeToRangeTemplate.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE FlexibleContexts, ScopedTypeVariables #-} +{-# LANGUAGE ScopedTypeVariables #-} -- | Transform a syntax tree with ranges to a syntax tree that has range templates. Cuts the ranges of children -- from the ranges of their parents and replaces it with placeholders.
Language/Haskell/Tools/PrettyPrint/Prepare/SourceTemplate.hs view
@@ -1,4 +1,9 @@-{-# LANGUAGE DeriveDataTypeable, FlexibleContexts, FlexibleInstances, RecordWildCards, TemplateHaskell, TypeFamilies #-} +{-# LANGUAGE DeriveDataTypeable #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE TemplateHaskell #-} +{-# LANGUAGE TypeFamilies #-} -- | The final version of the source annotation. Each node contains its original textual format, with the places of -- the children specified by placeholders.
Language/Haskell/Tools/PrettyPrint/Prepare/SourceTemplateHelpers.hs view
@@ -1,4 +1,5 @@-{-# LANGUAGE FlexibleContexts, FlexibleInstances, OverloadedStrings #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE OverloadedStrings #-} -- | Helper functions for working with source templates module Language.Haskell.Tools.PrettyPrint.Prepare.SourceTemplateHelpers where @@ -77,6 +78,7 @@ indented :: ListInfo SrcTemplateStage -> ListInfo SrcTemplateStage indented = (srcTmpIndented .= Just []) . (srcTmpDefaultSeparator .= "\n") --- | Concatenates two source templates to produce a new template with all child elements. -(<>) :: SpanInfo SrcTemplateStage -> SpanInfo SrcTemplateStage -> SpanInfo SrcTemplateStage -SourceTemplateNode sp1 el1 _ _ <> SourceTemplateNode sp2 el2 _ _ = SourceTemplateNode (combineSrcSpans sp1 sp2) (el1 ++ el2) 0 Nothing +-- Concatenates two source templates to produce a new template with all child elements. +instance Semigroup (SpanInfo SrcTemplateStage) where + SourceTemplateNode sp1 el1 _ _ <> SourceTemplateNode sp2 el2 _ _ + = SourceTemplateNode (combineSrcSpans sp1 sp2) (el1 ++ el2) 0 Nothing
Language/Haskell/Tools/PrettyPrint/RoseTree.hs view
@@ -1,4 +1,6 @@-{-# LANGUAGE FlexibleContexts, LambdaCase, RecordPuns #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE LambdaCase #-} +{-# LANGUAGE NamedFieldPuns #-} -- | A simpler representation of the original AST. module Language.Haskell.Tools.PrettyPrint.RoseTree where
haskell-tools-prettyprint.cabal view
@@ -1,5 +1,5 @@ name: haskell-tools-prettyprint -version: 1.0.1.1 +version: 1.1.0.0 synopsis: Pretty printing of Haskell-Tools AST description: Converts the Haskell-Tools AST to text. Prepares the AST for this conversion. If the AST was created from the GHC AST this pretty printing will result in the original source code. Generated AST parts will get the default formatting. Works using the source annotations that are present in the AST. Creates a rose tree first to simplify the conversion. homepage: https://github.com/haskell-tools/haskell-tools @@ -22,13 +22,13 @@ , Language.Haskell.Tools.PrettyPrint.Prepare.SourceTemplate , Language.Haskell.Tools.PrettyPrint.Prepare.SourceTemplateHelpers , Language.Haskell.Tools.PrettyPrint.Prepare.PlaceComments - build-depends: base >= 4.10 && < 4.11 + build-depends: base >= 4.11 && < 4.12 , mtl >= 2.2 && < 2.3 , containers >= 0.5 && < 0.6 , references >= 0.3 && < 0.4 , uniplate >= 1.6 && < 1.7 , split >= 0.2 && < 0.3 , text >= 1.2 && < 1.3 - , ghc >= 8.2 && < 8.3 - , haskell-tools-ast >= 1.0 && < 1.1 + , ghc >= 8.4 && < 8.5 + , haskell-tools-ast >= 1.1 && < 1.2 default-language: Haskell2010