interpol 0.2.1 → 0.2.2
raw patch · 5 files changed
+73/−13 lines, 5 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Text.Interpol: (^-^) :: Interpol a => String -> a -> String
- Text.Interpol: instance [overlap ok] Interpol [Char]
- Text.Interpol: instance [overlap ok] Show a => Interpol a
+ Text.Interpol: (^-^, interpol) :: (ToString a, ToString b) => a -> b -> String
+ Text.Interpol: class ToString a
+ Text.Interpol: instance [overlap ok] Show a => ToString a
+ Text.Interpol: instance [overlap ok] ToString Char
+ Text.Interpol: instance [overlap ok] ToString [Char]
Files
- Makefile +1/−0
- NEWS.md +15/−0
- Test/Unit.hs +30/−0
- Text/Interpol.hs +17/−7
- interpol.cabal +10/−6
Makefile view
@@ -31,6 +31,7 @@ $(foreach t,$(TESTS1),cd Test && $(GHC) -F -pgmF interpol $(t)${\n}) $(foreach t,$(TESTS2),cd Test && $(GHC) $(t)${\n}) $(foreach t,$(TESTS1) $(TESTS2),cd Test && [ "`./$(t)`" = "I have 23 apples." ]${\n})+ runhaskell Test/Unit.hs dist/setup-config: interpol.cabal cabal configure
+ NEWS.md view
@@ -0,0 +1,15 @@+News+====++v0.2.2+------++Bug-fix release for `v0.2.1`. All API changes are backwards+compatible: the ToString type-class is exported. Fixes the+interpolation of `Char`s (thank you [nh2](https://github.com/nh2)).++v0.2.1+------++Bug-fix release for `v0.2.0`. It does not change the API in any way,+but adds a few more tests and some more documentation.
+ Test/Unit.hs view
@@ -0,0 +1,30 @@+module Main where++import System.Exit ( exitFailure )+import Test.HUnit+import Text.Interpol++main :: IO ()+main = do+ runCounts <- runTestTT $ test [ toStringTests ]+ if failures runCounts + errors runCounts == 0+ then+ putStrLn "All unit tests pass :)"+ else do+ putStrLn "Failures or errors occured :'("+ exitFailure++toStringTests :: Test+toStringTests =+ test [ "string" ~: TestCase $ do+ assertEqual "" "I have apples" ("I " ^-^ "have " ^-^ "apples")+ , "char" ~: TestCase $ do+ assertEqual "" "Triple 'X'" ("Triple " ^-^ 'X')+ , "number" ~: TestCase $ do+ assertEqual "" "Am 21 years old" ("Am " ^-^ (21 :: Int) ^-^+ " years old")+ , "first" ~: TestCase $ do+ assertEqual "" "21 is my age" ((21 :: Int) ^-^ " is my age")+ , "utf" ~: TestCase $ do+ assertEqual "" "Umlaut: 'ü'" ("Umlaut: " ^-^ 'ü')+ ]
Text/Interpol.hs view
@@ -3,6 +3,8 @@ -- | Support module for the @interpol@ preprocessor. module Text.Interpol ( (^-^)+ , interpol+ , ToString ) where infixl 3 ^-^@@ -16,14 +18,22 @@ -- x ^-^ y = x ++ y -- x ^-^ y = x ++ show y -- @-(^-^) :: Interpol a => String -> a -> String+--+-- For all intents and purposes, the 'ToString' type-class is a+-- wrapper around 'Show', so any type that has an instance for 'Show'+-- will also have an instance for 'Interpol'.+(^-^), interpol :: (ToString a, ToString b) => a -> b -> String (^-^) = interpol+interpol a b = toString a ++ toString b -class Interpol a where- interpol :: String -> a -> String+class ToString a where+ toString :: a -> String -instance Interpol [Char] where- interpol s x = s ++ x+instance ToString [Char] where+ toString = id -instance Show a => Interpol a where- interpol s x = s ++ show x+instance ToString Char where+ toString c = '\'' : c : "'"++instance Show a => ToString a where+ toString = show
interpol.cabal view
@@ -1,5 +1,5 @@ Name: interpol-Version: 0.2.1+Version: 0.2.2 Cabal-Version: >= 1.6 License: GPL-3 License-File: LICENSE@@ -8,10 +8,13 @@ Maintainer: scvalex@gmail.com Homepage: https://github.com/scvalex/interpol Category: Source-tools, Language-Synopsis: GHC preprocessor to enable variable interpolation in strings+Synopsis: GHC preprocessor and library to enable variable interpolation in strings Build-type: Simple-Description: This preprocessor enables variable interpolation in strings.- See the README.md file for details.+Description:+ This preprocessor enables variable interpolation in strings.+ Alternatively, the library may be used.+ .+ See the README.md file for details. Extra-source-files: Makefile, Test/JustShow.hs,@@ -22,9 +25,10 @@ Test/PureString.hs, Test/Simple.hs, Test/Standalone.hs,- Test/String.hs+ Test/String.hs,+ Test/Unit.hs -Data-files: README.md+Data-files: README.md, NEWS.md Source-repository head Type: git