packages feed

th-format 0.1.0.0 → 0.1.1.0

raw patch · 3 files changed

+10/−5 lines, 3 files

Files

src/Data/Format.hs view
@@ -21,6 +21,7 @@   ) where  import           Control.Applicative+import           Control.Exception           (SomeException) import           Data.Char import           Data.Text                   (Text) import qualified Data.Text                   as Text@@ -31,9 +32,9 @@ import           Language.Haskell.TH.Syntax import           Text.Earley --- | This is just 'mconcat', reexported under a specialized name in--- order to avoid namespace clashes.-fmtConcat :: Monoid a => [a] -> a+-- | This is just specialized 'mconcat', reexported under a+-- specialized name in order to avoid namespace clashes.+fmtConcat :: [Text] -> Text fmtConcat = mconcat  -- | Type class which needs to be implemented by types that should be@@ -46,6 +47,9 @@   formatText :: a -> Text  instance Format Int where+  formatText = tshow++instance Format SomeException where   formatText = tshow  instance Format String where
test/Data/Format/Test.hs view
@@ -32,4 +32,5 @@      , testCase "Simple interpolations delimited by ws" ([fmt|$foo $foo|] @=? "FOO FOO")      , testCase "Boolean toggle interpolation" (([fmt|${if toggle then ("on" :: Text) else "off"}|] :: Text) @=? "on")      , testCase "Boolean toggle interpolation negated" (([fmt|${if (not toggle) then ("on" :: Text) else "off"}|] :: Text) @=? "off")+     , testCase "Code interpolation surrounded by text" (([fmt|Hello ${mconcat ["hi", " ", "hi"] :: Text}!|]) @=? "Hello hi hi!")      ]
th-format.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 4eb13b04d84d5d19948270617adaffdadfb358b7dfefe592f205f7eeeb2ff715+-- hash: 3e13f6d44296a186bbe36573b7e53289818efe4f6ff8d24435f8bc11a684a447  name:           th-format-version:        0.1.0.0+version:        0.1.1.0 synopsis:       Template Haskell based support for format strings description:    This package implements a Template Haskell quasi quoter for format strings. category:       Data