raw-strings-qq 1.0.2 → 1.1
raw patch · 5 files changed
+60/−5 lines, 5 filesdep +HUnitdep +raw-strings-qqdep ~base
Dependencies added: HUnit, raw-strings-qq
Dependency ranges changed: base
Files
- ChangeLog +7/−0
- Text/RawString/QQ.hs +11/−3
- examples/RawRegex.hs +2/−0
- raw-strings-qq.cabal +12/−2
- test/Test.hs +28/−0
+ ChangeLog view
@@ -0,0 +1,7 @@+-*-change-log-*-++1.1 Mikhail Glushenkov <mikhail.glushenkov@gmail.com>+ * CRLF line endings are now normalised to LF (#1).++1.0 Mikhail Glushenkov <mikhail.glushenkov@gmail.com>+ * Initial release.
Text/RawString/QQ.hs view
@@ -57,7 +57,7 @@ r :: QuasiQuoter r = QuasiQuoter { -- Extracted from dead-simple-json.- quoteExp = return . LitE . StringL,+ quoteExp = return . LitE . StringL . normaliseNewlines, quotePat = \_ -> fail "illegal raw string QuasiQuote \ \(allowed as expression only, used as a pattern)",@@ -68,7 +68,8 @@ } {-| A variant of 'r' that interprets the @\"|~]\"@ sequence as @\"|]\"@,-@\"|~~]\"@ as @\"|~]\"@ and, in general, @\"|~^n]\"@ as @\"|~^(n-1)]\"@.+@\"|~~]\"@ as @\"|~]\"@ and, in general, @\"|~^n]\"@ as @\"|~^(n-1)]\"@+for n >= 1. Usage: @@ -83,7 +84,7 @@ -} rQ :: QuasiQuoter rQ = QuasiQuoter {- quoteExp = return . LitE . StringL . escape_rQ,+ quoteExp = return . LitE . StringL . escape_rQ . normaliseNewlines, quotePat = \_ -> fail "illegal raw string QuasiQuote \ \(allowed as expression only, used as a pattern)",@@ -102,3 +103,10 @@ (']':rs) -> '|':tildas ++ ']':escape_rQ rs rs -> '|':'~':tildas ++ escape_rQ rs escape_rQ (x:xs) = x : escape_rQ xs++-- See https://github.com/23Skidoo/raw-strings-qq/issues/1 and+-- https://ghc.haskell.org/trac/ghc/ticket/11215.+normaliseNewlines :: String -> String+normaliseNewlines [] = []+normaliseNewlines ('\r':'\n':cs) = '\n':normaliseNewlines cs+normaliseNewlines (c:cs) = c:normaliseNewlines cs
examples/RawRegex.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE QuasiQuotes #-}+ module Main where
raw-strings-qq.cabal view
@@ -1,5 +1,5 @@ name: raw-strings-qq-version: 1.0.2+version: 1.1 synopsis: Raw string literals for Haskell. description: @@ -17,11 +17,12 @@ license-file: LICENSE author: Mikhail Glushenkov maintainer: mikhail.glushenkov@gmail.com-copyright: (c) Mikhail Glushenkov 2013+copyright: (c) Mikhail Glushenkov 2013-2015 category: Text build-type: Simple cabal-version: >=1.8 extra-source-files: examples/RawRegex.hs+ ChangeLog source-repository head type: git@@ -30,3 +31,12 @@ library exposed-modules: Text.RawString.QQ build-depends: base <= 10, template-haskell >= 2.5++test-suite tests+ hs-source-dirs: test+ main-is: Test.hs+ type: exitcode-stdio-1.0+ build-depends: base,+ raw-strings-qq,+ HUnit+ ghc-options: -Wall
+ test/Test.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE QuasiQuotes #-}++module Main+ where++import Test.HUnit+import Text.RawString.QQ+import System.Exit++multilineUnixNewlines :: String+multilineUnixNewlines = [r|FOO+BAR|]++multilineWindowsNewlines :: String+multilineWindowsNewlines = [r|FOO +BAR|]++main :: IO ()+main = defaultMain $ test [+ "Windows newlines" ~: (multilineUnixNewlines ~=? multilineWindowsNewlines)+ ]++defaultMain :: Test -> IO ()+defaultMain t = do+ cnts <- runTestTT t+ case failures cnts + errors cnts of+ 0 -> exitWith $ ExitSuccess+ n -> exitWith $ ExitFailure n