packages feed

interpolate 0.0.3 → 0.0.4

raw patch · 3 files changed

+26/−3 lines, 3 filesdep ~haskell-src-meta

Dependency ranges changed: haskell-src-meta

Files

interpolate.cabal view
@@ -1,5 +1,5 @@ name:             interpolate-version:          0.0.3+version:          0.0.4 license:          MIT license-file:     LICENSE copyright:        (c) 2013 Simon Hengel@@ -23,6 +23,7 @@       src   exposed-modules:       Data.String.Interpolate+      Data.String.Interpolate.IsString   other-modules:       Data.String.Interpolate.Util       Data.String.Interpolate.Parse@@ -36,7 +37,7 @@   type:       exitcode-stdio-1.0   ghc-options:-      -Wall -Werror+      -Wall   hs-source-dirs:       src, test   main-is:@@ -56,7 +57,7 @@   type:       exitcode-stdio-1.0   ghc-options:-      -Wall -Werror+      -Wall   hs-source-dirs:       test   main-is:
+ src/Data/String/Interpolate/IsString.hs view
@@ -0,0 +1,21 @@+{-# LANGUAGE TemplateHaskell #-}+module Data.String.Interpolate.IsString (i) where++import           Data.String+import           Language.Haskell.TH.Quote (QuasiQuoter(..))++import qualified Data.String.Interpolate as I++-- |+-- Like `I.i`, but constructs a value of type+--+-- > IsString a => a+i :: QuasiQuoter+i = QuasiQuoter {+    quoteExp = \s -> [|fromString $(quoteExp I.i $ s)|]+  , quotePat = err "pattern"+  , quoteType = err "type"+  , quoteDec = err "declaration"+  }+  where+    err name = error ("Data.String.Interpolate.IsString.i: This QuasiQuoter can not be used as a " ++ name ++ "!")
src/Data/String/Interpolate/Util.hs view
@@ -8,6 +8,7 @@  toString :: Show a => a -> String toString a = let s = show a in fromMaybe s (readMaybe s)+{-# NOINLINE toString #-} {-# RULES "toString/String" toString = id #-} {-# RULES "toString/Int" toString = show :: Int -> String #-} {-# RULES "toString/Integer" toString = show :: Integer -> String #-}