packages feed

directory-layout 0.7.1.0 → 0.7.2.0

raw patch · 3 files changed

+38/−18 lines, 3 filesdep +command-qqPVP ok

version bump matches the API change (PVP)

Dependencies added: command-qq

API changes (from Hackage documentation)

+ System.Directory.Layout.QQ: dedentSubst :: QuasiQuoter

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+0.7.2.0+=======++  * Added `dedentSubst`, `dedent` with variable substitution+ 0.7.1.0 ======= 
directory-layout.cabal view
@@ -1,5 +1,5 @@ name:                directory-layout-version:             0.7.1.0+version:             0.7.2.0 synopsis:            Directory layout DSL description:   Making, fitting, printing directory layouts@@ -21,7 +21,7 @@ source-repository this   type:     git   location: https://github.com/supki/directory-layout-  tag:      0.7.1.0+  tag:      0.7.2.0  library   default-language:@@ -29,6 +29,7 @@   build-depends:       base                 >= 4.6   && < 5     , bytestring+    , command-qq           >= 0.2.2.0     , containers     , directory     , filepath@@ -74,6 +75,7 @@   build-depends:       base >= 4.6     , bytestring+    , command-qq     , containers     , directory     , filepath
src/System/Directory/Layout/QQ.hs view
@@ -1,6 +1,9 @@ {-# LANGUAGE TemplateHaskell #-} -- | Convenience quasiquoter to ease the pain working with multiline strings-module System.Directory.Layout.QQ (dedent) where+module System.Directory.Layout.QQ+  ( dedent+  , dedentSubst+  ) where  import           Control.Applicative import           Data.Char (isSpace)@@ -12,28 +15,49 @@ import           Language.Haskell.TH.Syntax (liftString) import           Language.Haskell.TH (Q, Exp) import           Prelude hiding (foldr)+import           System.Command.QQ (substituteVars, quoter)  +-- $setup+-- >>> :set -XQuasiQuotes+ -- | A handy quasiquoter to work with the multiline file contents -- -- Strips the longest common leading spaces segment. All spacey characters are treated -- equally. The first line is ignored if it's spaces only. ----- >>> :set -XQuasiQuotes -- >>> :{ -- putStr [dedent| --   hello --     world --     !---   |]+-- |] -- :} -- hello --   world --   ! dedent :: QuasiQuoter-dedent = quoter $-  liftString . withLines (strip . trim (all isSpace))+dedent = dedentWith liftString +-- | 'dedent' with variable substitution+--+-- >>> let hello = "bye" :: String+-- >>> :{+-- putStr [dedentSubst|+--   #{hello}+--     world+--     !+-- |]+-- :}+-- bye+--   world+--   !+dedentSubst :: QuasiQuoter+dedentSubst = dedentWith substituteVars++dedentWith :: (String -> Q Exp) -> QuasiQuoter+dedentWith f = quoter $ f . withLines (strip . trim (all isSpace))+ withLines :: (Seq String -> Seq String) -> String -> String withLines f = unsplit '\n' . toList . f . Seq.fromList . split '\n' @@ -77,14 +101,3 @@   lmin (Just x) (Just y) = Just (min x y)   lmin Nothing x = x   lmin x Nothing = x--quoter :: (String -> Q Exp) -> QuasiQuoter-quoter quote = QuasiQuoter-  { quoteExp  = quote-  , quotePat  = failure "patterns"-  , quoteType = failure "types"-  , quoteDec  = failure "declarations"-  }- where-  failure kind =-    fail $ "this quasiquoter does not support splicing " ++ kind