string-qq-0.0.6/0000755000000000000000000000000007346545000011633 5ustar0000000000000000string-qq-0.0.6/LICENSE0000644000000000000000000000031507346545000012637 0ustar0000000000000000To the extent possible under law, 唐鳳 has waived all copyright and related or neighboring rights to string-qq. This work is published from Taiwan. string-qq-0.0.6/Setup.hs0000644000000000000000000000005607346545000013270 0ustar0000000000000000import Distribution.Simple main = defaultMain string-qq-0.0.6/src/Data/String/0000755000000000000000000000000007346545000014541 5ustar0000000000000000string-qq-0.0.6/src/Data/String/QQ.hs0000644000000000000000000000232307346545000015416 0ustar0000000000000000{-# LANGUAGE TemplateHaskell, CPP #-} -- | QuasiQuoter for non-interpolated strings, texts and bytestrings. -- -- The "s" quoter contains a multi-line string with no interpolation at all, -- except that the leading newline is trimmed and carriage returns stripped. -- -- @ -- {-\# LANGUAGE QuasiQuotes #-} -- import Data.Text (Text) -- import Data.String.QQ -- foo :: Text -- "String", "ByteString" etc also works -- foo = [s| -- Well here is a -- multi-line string! -- |] -- @ -- -- Any instance of the IsString type is permitted. -- -- (For GHC versions 6, write "[$s||]" instead of "[s||]".) -- module Data.String.QQ (s) where import GHC.Exts (IsString(..)) import qualified Language.Haskell.TH as TH import Language.Haskell.TH.Quote -- | QuasiQuoter for a non-interpolating IsString literal. The pattern portion is undefined. s :: QuasiQuoter s = QuasiQuoter ((\a -> [|fromString a|]) . trimLeadingNewline . removeCRs) (error "Cannot use q as a pattern") #if (__GLASGOW_HASKELL__ >= 700) (error "Cannot use q as a type") (error "Cannot use q as a dec") #endif where removeCRs = filter (/= '\r') trimLeadingNewline ('\n':xs) = xs trimLeadingNewline xs = xs string-qq-0.0.6/string-qq.cabal0000644000000000000000000000220307346545000014541 0ustar0000000000000000Name: string-qq Version: 0.0.6 License: PublicDomain License-file: LICENSE Category: Data Author: Audrey Tang Copyright: Audrey Tang Maintainer: Audrey Tang Stability: unstable Cabal-Version: >= 1.10 Build-Type: Simple Synopsis: QuasiQuoter for non-interpolated strings, texts and bytestrings. Description: QuasiQuoter for non-interpolated strings, texts and bytestrings, useful for writing multi-line IsString literals. Tested-With: GHC==6.10.1 GHC==7.0.2 GHC==8.2.2 GHC==8.6.5 GHC==9.4.8 GHC==9.6.3 GHC==9.8.1 Source-Repository head type: git location: https://github.com/audreyt/string-qq.git library default-extensions: TemplateHaskell build-depends: base > 3 && < 6, template-haskell >= 2 && < 3 hs-source-dirs: src exposed-modules: Data.String.QQ default-language: Haskell2010 test-suite string-qq-test type: exitcode-stdio-1.0 hs-source-dirs: tests main-is: Test.hs build-depends: base, string-qq, HUnit >=1.6 && <1.7, text >=1.2 && <3 default-language: Haskell2010 string-qq-0.0.6/tests/0000755000000000000000000000000007346545000012775 5ustar0000000000000000string-qq-0.0.6/tests/Test.hs0000644000000000000000000000211507346545000014247 0ustar0000000000000000{-# LANGUAGE QuasiQuotes, ExtendedDefaultRules, CPP #-} module Main where import Data.Text import Data.String.QQ import Test.HUnit #if (__GLASGOW_HASKELL__ >= 700) test0 = assertBool "" ([s||] == "") test1 = assertBool "" ([s|1|] == "1") test2 = assertBool "" ([s|2|] == pack "2") test0' = assertBool "" ([s| |] == "") test1' = assertBool "" ([s| 1|] == "1") test2' = assertBool "" ([s| 2|] == pack "2") #else test0 = assertBool "" ([$s||] == "") test1 = assertBool "" ([$s|1|] == "1") test2 = assertBool "" ([$s|2|] == pack "2") test0' = assertBool "" ([$s| |] == "") test1' = assertBool "" ([$s| 1|] == "1") test2' = assertBool "" ([$s| 2|] == pack "2") #endif tests = TestList [ TestLabel "Empty String" $ TestCase test0 , TestLabel "String instance" $ TestCase test1 , TestLabel "Text instance" $ TestCase test2 , TestLabel "Empty String with trimmed leading newline" $ TestCase test0' , TestLabel "String instance with trimmed leading newline" $ TestCase test1' , TestLabel "Text instance with trimmed leading newline" $ TestCase test2' ] main = runTestTT tests