haskell-src-exts-util 0.2.1.2 → 0.2.2
raw patch · 5 files changed
+46/−20 lines, 5 filesdep +semigroupsdep ~haskell-src-extssetup-changedPVP ok
version bump matches the API change (PVP)
Dependencies added: semigroups
Dependency ranges changed: haskell-src-exts
API changes (from Hackage documentation)
Files
- Setup.hs +2/−0
- changelog.md +6/−0
- haskell-src-exts-util.cabal +14/−4
- src/Language/Haskell/Exts/Bracket.hs +14/−14
- src/Language/Haskell/Exts/FreeVars.hs +10/−2
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ changelog.md view
@@ -0,0 +1,6 @@+# 0.2.2+ - Improved handling of OverloadedLabel syntax, thanks to Neil M.+ - Changed the treatment of multiple function composition in `needParen`.+ The new treatment is less keen to remove parentheses.+ Note that this is a change of behavior.+ - GHC 8.4 compatibility, courtesy of Ryan G. Scott
haskell-src-exts-util.cabal view
@@ -1,32 +1,42 @@--- This file has been generated from package.yaml by hpack version 0.17.1.+-- This file has been generated from package.yaml by hpack version 0.20.0. -- -- see: https://github.com/sol/hpack+--+-- hash: b7fcbc93356ff0debc245de9340f49810ecf46a3515ee53e6af6ae762443c658 name: haskell-src-exts-util-version: 0.2.1.2+version: 0.2.2 synopsis: Helper functions for working with haskell-src-exts trees-description: see README.md+description: Helper functions for working with haskell-src-exts trees. category: language homepage: https://github.com/pepeiborra/haskell-src-exts-util+bug-reports: https://github.com/pepeiborra/haskell-src-exts-util/issues author: Neil Mitchell, Jose Iborra maintainer: pepeiborra@gmail.com copyright: All Rights Reserved license: BSD3 license-file: LICENSE+tested-with: GHC==8.4.1, GHC==8.2.1, GHC==8.0.2 build-type: Simple cabal-version: >= 1.10 extra-source-files:+ changelog.md README.md +source-repository head+ type: git+ location: https://github.com/pepeiborra/haskell-src-exts-util+ library hs-source-dirs: src build-depends:- base < 5+ base <5 , containers , data-default , haskell-src-exts+ , semigroups , transformers , uniplate exposed-modules:
src/Language/Haskell/Exts/Bracket.hs view
@@ -42,19 +42,20 @@ addParen = Paren def isAtom x = case x of- Paren{} -> True- Tuple{} -> True- List{} -> True- LeftSection{} -> True- RightSection{} -> True- TupleSection{} -> True- RecConstr{} -> True- ListComp{} -> True- EnumFrom{} -> True- EnumFromTo{} -> True- EnumFromThen{} -> True- EnumFromThenTo{} -> True- _ -> isLexeme x+ Paren{} -> True+ Tuple{} -> True+ List{} -> True+ LeftSection{} -> True+ RightSection{} -> True+ TupleSection{} -> True+ RecConstr{} -> True+ ListComp{} -> True+ EnumFrom{} -> True+ EnumFromTo{} -> True+ EnumFromThen{} -> True+ EnumFromThenTo{} -> True+ OverloadedLabel{} -> True+ _ -> isLexeme x -- note: i is the index in children, not in the AST needBracket i parent child@@ -69,7 +70,6 @@ | App{} <- parent, i == 0, App{} <- child = False | ExpTypeSig{} <- parent, i == 0, isApp child = False | Paren{} <- parent = False- | isDotApp parent, isDotApp child, i == 1 = False | RecConstr{} <- parent = False | RecUpdate{} <- parent, i /= 0 = False | Case{} <- parent, i /= 0 || isAnyApp child = False
src/Language/Haskell/Exts/FreeVars.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-}@@ -13,9 +14,11 @@ , AllVars(..) ) where +import Control.Monad import Data.Data import Data.Generics.Uniplate.Data import Data.Monoid (Monoid(..))+import Data.Semigroup (Semigroup(..)) import Data.Set (Set) import qualified Data.Set as Set import Language.Haskell.Exts@@ -28,9 +31,14 @@ data Vars = Vars {bound :: Set (Name ()), free :: Set (Name ())} +instance Semigroup Vars where+ Vars x1 x2 <> Vars y1 y2 = Vars (x1 ^+ y1) (x2 ^+ y2)+ instance Monoid Vars where mempty = Vars Set.empty Set.empty- mappend (Vars x1 x2) (Vars y1 y2) = Vars (x1 ^+ y1) (x2 ^+ y2)+#if !(MIN_VERSION_base(4,11,0))+ mappend = (<>)+#endif mconcat fvs = Vars (Set.unions $ map bound fvs) (Set.unions $ map free fvs) class AllVars a where@@ -65,7 +73,7 @@ unqualOp (QVarOp _ x) = unqualNames x unqualOp (QConOp _ x) = unqualNames x -withNoLoc x = fmap (const()) x+withNoLoc = void instance (Data s, Ord s) => FreeVars (Set (Name s)) where freeVars = Set.map withNoLoc