marvin-interpolate 0.4.0 → 1.0
raw patch · 6 files changed
+38/−28 lines, 6 filesdep ~marvin-interpolatePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: marvin-interpolate
API changes (from Hackage documentation)
- Marvin.Interpolate: parser :: ParseM Parsed
- Marvin.Interpolate.String: showListStr :: ShowStr a => [a] -> String
- Marvin.Interpolate.Text: showListT :: ShowT a => [a] -> Text
- Marvin.Interpolate.Text.Lazy: showListL :: ShowL a => [a] -> Text
+ Marvin.Interpolate.String: instance Marvin.Interpolate.String.ShowStr a => Marvin.Interpolate.String.ShowStr [a]
+ Marvin.Interpolate.Text: instance Marvin.Interpolate.Text.ShowT a => Marvin.Interpolate.Text.ShowT [a]
+ Marvin.Interpolate.Text.Lazy: instance Marvin.Interpolate.Text.Lazy.ShowL a => Marvin.Interpolate.Text.Lazy.ShowL [a]
Files
- marvin-interpolate.cabal +4/−2
- src/Marvin/Interpolate.hs +4/−5
- src/Marvin/Interpolate/String.hs +8/−7
- src/Marvin/Interpolate/Text.hs +8/−7
- src/Marvin/Interpolate/Text/Lazy.hs +8/−7
- test/Spec.hs +6/−0
marvin-interpolate.cabal view
@@ -1,5 +1,5 @@ name: marvin-interpolate-version: 0.4.0+version: 1.0 cabal-version: >=1.10 build-type: Simple license: BSD3@@ -34,6 +34,8 @@ text >=1.2.2.1 && <1.3, mtl >=2.2.1 && <2.3 default-language: Haskell2010+ default-extensions: FlexibleInstances OverloadedStrings+ TemplateHaskell UndecidableInstances hs-source-dirs: src other-modules: Util@@ -43,7 +45,7 @@ main-is: Spec.hs build-depends: base >=4.9.0.0 && <4.10,- marvin-interpolate >=0.4.0 && <0.5,+ marvin-interpolate ==1.0.*, hspec >=2.2.4 && <2.3, text >=1.2.2.1 && <1.3 default-language: Haskell2010
src/Marvin/Interpolate.hs view
@@ -15,7 +15,6 @@ , iq -- * Internals/extension points , interpolateInto- , parser ) where @@ -45,7 +44,7 @@ parseString :: ParseM (Either String String) parseString = do- chunk <- many $ noneOf ['#']+ chunk <- many $ satisfy (/= '#') fmap (Right . (chunk ++)) $ (eof >> return "") <|> (lookAhead (try (char '#' >> anyChar)) >>= endOrEscape) <|> fmap return anyChar where endOrEscape :: Char -> ParseM String@@ -56,7 +55,7 @@ parseInterpolation :: ParseM (Either String String)-parseInterpolation = (try $ string "#{") >> (Left <$> parseExpr)+parseInterpolation = try (string "#{") >> (Left <$> parseExpr) where parseExpr = do chunk <- many $ noneOf ['}', '"', '\'', '{']@@ -130,7 +129,7 @@ -- | __i__nterpolate __s__plice ----- Template Haskell splice function, used like @$(is "my str %{expr}")@+-- Template Haskell splice function, used like @$(is "my str #{expr}")@ -- -- Performs no conversion on interpolated expressions like @expr@. is :: String -> Q Exp@@ -139,7 +138,7 @@ -- | __i__nterpolate __q__uoter ----- QuasiQuoter, used like @[i|my str %{expr}|]@+-- QuasiQuoter, used like @[iq|my str #{expr}|]@ -- -- Performs no conversion on interpolated expressions like @expr@. iq :: QuasiQuoter
src/Marvin/Interpolate/String.hs view
@@ -9,14 +9,10 @@ Please refer to the documentation at https://marvin.readthedocs.io/en/latest/interpolation.html for examples and explanations on how to use this library. -}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE UndecidableInstances #-} module Marvin.Interpolate.String ( isS, iqS -- * Conversion class- , ShowStr(..)+ , ShowStr(showStr) ) where @@ -38,10 +34,15 @@ showListStr :: [a] -> String showListStr l = "[" <> intercalate ", " (map showStr l) <> "]" + {-# MINIMAL showStr #-}+ instance ShowStr Char where showStr = show showListStr = id +instance ShowStr a => ShowStr [a] where+ showStr = showListStr+ instance ShowStr T.Text where showStr = T.unpack @@ -54,7 +55,7 @@ -- | __i__nterpolate __s__plice to __S__tring ----- Template Haskell splice function, used like @$(isS "my str %{expr}")@+-- Template Haskell splice function, used like @$(isS "my str #{expr}")@ -- -- converts all expressions to 'String' by calling 'showStr' on the result. isS :: String -> Q Exp@@ -63,7 +64,7 @@ -- | __i__nterpolate __q__uoter to __S__tring ----- QuasiQuoter, used like @[iS|my str %{expr}|]@+-- QuasiQuoter, used like @[iqS|my str #{expr}|]@ -- -- converts all expressions to 'String' by calling 'showStr' on the result. iqS :: QuasiQuoter
src/Marvin/Interpolate/Text.hs view
@@ -9,14 +9,10 @@ Please refer to the documentation at https://marvin.readthedocs.io/en/latest/interpolation.html for examples and explanations on how to use this library. -}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE UndecidableInstances #-} module Marvin.Interpolate.Text ( isT, iqT -- * Conversion class- , ShowT(..)+ , ShowT(showT) ) where @@ -37,6 +33,11 @@ showListT :: [a] -> Text showListT l = "[" <> intercalate ", " (map showT l) <> "]" + {-# MINIMAL showT #-}++instance ShowT a => ShowT [a] where+ showT = showListT+ instance ShowT Text where showT = id @@ -53,7 +54,7 @@ -- | __i__nterpolate __s__plice to __T__ext ----- Template Haskell splice function, used like @$(isT "my str %{expr}")@+-- Template Haskell splice function, used like @$(isT "my str #{expr}")@ -- -- converts all expressions to 'Text' by calling 'showT' on the result. isT :: String -> Q Exp@@ -62,7 +63,7 @@ -- | __i__nterpolate __q__uoter to __T__ext ----- QuasiQuoter, used like @[iT|my str %{expr}|]@+-- QuasiQuoter, used like @[iqT|my str #{expr}|]@ -- -- converts all expressions to 'Text' by calling 'showT' on the result. iqT :: QuasiQuoter
src/Marvin/Interpolate/Text/Lazy.hs view
@@ -9,14 +9,10 @@ Please refer to the documentation at https://marvin.readthedocs.io/en/latest/interpolation.html for examples and explanations on how to use this library. -}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TemplateHaskell #-}-{-# LANGUAGE UndecidableInstances #-} module Marvin.Interpolate.Text.Lazy ( isL, iqL -- * Conversion class- , ShowL(..)+ , ShowL(showL) ) where @@ -37,6 +33,11 @@ showListL :: [a] -> L.Text showListL l = "[" <> L.intercalate ", " (map showL l) <> "]" + {-# MINIMAL showL #-}++instance ShowL a => ShowL [a] where+ showL = showListL+ instance ShowL L.Text where showL = id @@ -53,7 +54,7 @@ -- | __i__nterpolate __s__plice to __L__azy Text ----- Template Haskell splice function, used like @$(isLT "my str %{expr}")@+-- Template Haskell splice function, used like @$(isL "my str #{expr}")@ -- -- converts all expressions to 'L.Text' by calling 'showL' on the result. isL :: String -> Q Exp@@ -62,7 +63,7 @@ -- | __i__nterpolate __q__uoter to __L__azy Text ----- QuasiQuoter, used like @[iLT|my str %{expr}|]@+-- QuasiQuoter, used like @[iqL|my str #{expr}|]@ -- -- converts all expressions to 'L.Text' by calling 'showL' on the result. iqL :: QuasiQuoter
test/Spec.hs view
@@ -88,6 +88,8 @@ $(isS "#{G}") `shouldBe` "showStr" it "does not change Text" $ $(isS "#{\"str\" :: T.Text}") `shouldBe` "str"+ it "does not change String" $+ $(isS "#{\"str\" :: String}") `shouldBe` "str" describe "'isT' interpolation to Text" $ do it "calls show on Int" $@@ -96,6 +98,8 @@ $(isT "#{G}") `shouldBe` "showT" it "does not change Text" $ $(isT "#{\"str\" :: T.Text}") `shouldBe` "str"+ it "does not change String" $+ $(isT "#{\"str\" :: String}") `shouldBe` "str" describe "'isL' interpolation to lazy Text" $ do it "calls show on Int" $@@ -104,3 +108,5 @@ $(isL "#{G}") `shouldBe` "showL" it "does not change Text" $ $(isL "#{\"str\" :: T.Text}") `shouldBe` "str"+ it "does not change String" $+ $(isL "#{\"str\" :: String}") `shouldBe` "str"