yasi 0.1.1.0 → 0.1.1.1
raw patch · 5 files changed
+17/−9 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Yasi.Internal: interpolator :: Char -> (Exp -> Q Exp) -> QuasiQuoter
+ Yasi.Internal: interpolator :: Char -> (Exp -> Exp) -> QuasiQuoter
- Yasi.Internal: ipExpr :: Exp -> Exp -> [Segment] -> Q Exp
+ Yasi.Internal: ipExpr :: Exp -> (Exp -> Exp) -> [Segment] -> Q Exp
Files
- CHANGELOG.md +5/−1
- src/Yasi.hs +1/−1
- src/Yasi/Internal.hs +4/−4
- test/Interpolations.hs +6/−2
- yasi.cabal +1/−1
CHANGELOG.md view
@@ -1,6 +1,10 @@ # Revision history for yasi -## 0.1.1.0 -- 2021-02-13+## 0.1.1.1 -- 2021-02-14++ * Fix interaction of new variants and abstraction++## 0.1.1.0 -- 2021-02-14 * Add interpolator variants (with different return types)
src/Yasi.hs view
@@ -34,7 +34,7 @@ -- >>> import Data.ByteString (ByteString) int :: (TH.Exp -> TH.Exp) -> TH.QuasiQuoter-int f = interpolator '$' (pure . f)+int = interpolator '$' -- | The main interpolator, intended to be used with -- [@QuasiQuotes@](https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/exts/template_haskell.html#extension-QuasiQuotes).
src/Yasi/Internal.hs view
@@ -71,10 +71,10 @@ lit [] = [] lit ls = [Lit $ mconcat $ reverse ls] -ipExpr :: TH.Exp -> TH.Exp -> [Segment] -> TH.Q TH.Exp+ipExpr :: TH.Exp -> (TH.Exp -> TH.Exp) -> [Segment] -> TH.Q TH.Exp ipExpr cast combine segs = do (ls, lams) <- go segs- pure $ lams $ TH.AppE combine (TH.ListE ls)+ pure $ lams $ combine $ TH.ListE ls where go = \case [] -> pure ([], id)@@ -96,11 +96,11 @@ interpolator :: Char -> -- | postprocess the 'TH.Exp'- (TH.Exp -> TH.Q TH.Exp) ->+ (TH.Exp -> TH.Exp) -> TH.QuasiQuoter interpolator c pp = TH.QuasiQuoter {..} where- quoteExp = parseSegments c >=> ipExpr (TH.VarE 'stringy) (TH.VarE 'mconcat) >=> pp+ quoteExp = parseSegments c >=> ipExpr (TH.VarE 'stringy) (pp . TH.AppE (TH.VarE 'mconcat)) quotePat = const $ fail "pattern context not supported" quoteType = const $ fail "type context not supported" quoteDec = const $ fail "declaration context not supported"
test/Interpolations.hs view
@@ -30,11 +30,15 @@ let p = T.encodeUtf8 "℘" [i|℘$a℘$b℘$c℘|] === p <> a <> p <> T.encodeUtf8 b <> p <> T.encodeUtf8 (T.pack c) <> p, testProperty "abstractions" . property $ do- (a, b) <- (,) <$> forAll genText <*> forAll (Gen.integral $ Range.constant 0 1000)- [i|xxx-${}$show-yyy|] a (b :: Int) === "xxx-" <> a <> T.pack (show b) <> "-yyy"+ (a, b) <- (,) <$> forAll genText <*> forAll genInt+ [i|xxx-${}$show-yyy|] a (b :: Int) === "xxx-" <> a <> T.pack (show b) <> "-yyy",+ testProperty "variants" . property $ do+ (a, b) <- (,) <$> forAll genText <*> forAll genInt+ [iT|xxx-${}$show-yyy|] a (b :: Int) === "xxx-" <> a <> T.pack (show b) <> "-yyy" ] where genString = Gen.string range Gen.unicodeAll genText = Gen.text range Gen.unicodeAll genBS = Gen.bytes range range = Range.constant 0 20+ genInt = Gen.integral $ Range.constant 0 1000
yasi.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.4 name: yasi-version: 0.1.1.0+version: 0.1.1.1 synopsis: Yet another string interpolator description: