packages feed

nowdoc (empty) → 0.1.0.0

raw patch · 12 files changed

+201/−0 lines, 12 filesdep +basedep +nowdocdep +template-haskellsetup-changed

Dependencies added: base, nowdoc, template-haskell

Files

+ ChangeLog.md view
@@ -0,0 +1,3 @@+# Changelog for nowdoc++## Unreleased changes
+ LICENSE view
@@ -0,0 +1,30 @@+Copyright Author name here (c) 2018++All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are met:++    * Redistributions of source code must retain the above copyright+      notice, this list of conditions and the following disclaimer.++    * Redistributions in binary form must reproduce the above+      copyright notice, this list of conditions and the following+      disclaimer in the documentation and/or other materials provided+      with the distribution.++    * Neither the name of Author name here nor the names of other+      contributors may be used to endorse or promote products derived+      from this software without specific prior written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ README.md view
@@ -0,0 +1,1 @@+# nowdoc
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ nowdoc.cabal view
@@ -0,0 +1,58 @@+-- This file has been generated from package.yaml by hpack version 0.28.2.+--+-- see: https://github.com/sol/hpack+--+-- hash: 087ee2b1e9300c01bedb2232553e220d78e6f4c5308d0221029287e0cc914fe1++name:           nowdoc+version:        0.1.0.0+synopsis:       Here document without variable expansion like PHP Nowdoc+description:    Please see the README on GitHub at <https://github.com/YoshikuniJujo/nowdoc#readme>+category:       Text+homepage:       https://github.com/YoshikuniJujo/nowdoc#readme+bug-reports:    https://github.com/YoshikuniJujo/nowdoc/issues+author:         Yoshikuni Jujo+maintainer:     PAF01143@nifty.ne.jp+copyright:      2018 Yoshikuni Jujo+license:        BSD3+license-file:   LICENSE+build-type:     Simple+cabal-version:  >= 1.10+extra-source-files:+    ChangeLog.md+    README.md+    samples/sample0.hs+    samples/sample1.hs+    samples/sample2.hs+    samples/sample3.hs+    samples/sample4.hs++source-repository head+  type: git+  location: https://github.com/YoshikuniJujo/nowdoc++library+  exposed-modules:+      Text.Nowdoc+  other-modules:+      Paths_nowdoc+  hs-source-dirs:+      src+  build-depends:+      base >=4.7 && <5+    , template-haskell+  default-language: Haskell2010++test-suite nowdoc-test+  type: exitcode-stdio-1.0+  main-is: Spec.hs+  other-modules:+      Paths_nowdoc+  hs-source-dirs:+      test+  ghc-options: -threaded -rtsopts -with-rtsopts=-N+  build-depends:+      base >=4.7 && <5+    , nowdoc+    , template-haskell+  default-language: Haskell2010
+ samples/sample0.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE QuasiQuotes #-}++import Text.Nowdoc++main :: IO ()+main = putStr [nowdoc|+Now, fair Hippolyta, our nuptial hour+Draws on apace; four happy days brings in+Another moon: but, O, methinks, how slow+This old moon wanes! she lingers my desires,+Like to a step-dame or a dowager+Long withering out a young man revenue.+|]
+ samples/sample1.hs view
@@ -0,0 +1,9 @@+{-# LANGUAGE QuasiQuotes #-}++import Text.Nowdoc++main :: IO ()+main = putStr [nowdoc|+hello | ]+world |  ]+|]
+ samples/sample2.hs view
@@ -0,0 +1,15 @@+{-# LANGUAGE QuasiQuotes #-}++import Text.Nowdoc++main :: IO ()+main = putStr [nowdoc|+#include <stdio.h>++int+main(int argc, char *argv[])+{+	printf("Hello, world!\n");+	return 0;+}+|]
+ samples/sample3.hs view
@@ -0,0 +1,24 @@+{-# LANGUAGE QuasiQuotes #-}++import Text.Nowdoc++main :: IO ()+main = putStr message++message :: String+message = [nowdoc|+Two households, both alike in dignity,+In fair Verona, where we lay our scene,+From ancient grudge break to new mutiny,+Where civil blood makes civil hands unclean.+From forth the fatal loins of these two foes+A pair of star-cross'd lovers take their life;+Whose misadventured piteous overthrows+Do with their death bury their parents' strife.+The fearful passage of their death-mark'd love,+And the continuance of their parents' rage,+Which, but their children's end, nought could remove,+Is now the two hours' traffic of our stage;+The which if you with patient ears attend,+What here shall miss, our toil shall strive to mend.+|]
+ samples/sample4.hs view
@@ -0,0 +1,14 @@+{-# LANGUAGE QuasiQuotes #-}++import Text.Nowdoc++main :: IO ()+main = putStr src++src :: String+src = [nowdoc|+$hello = "hello"+$world = "world"++puts $hello, $world+|]
+ src/Text/Nowdoc.hs view
@@ -0,0 +1,30 @@+{-# OPTIONS_GHC -Wall -fno-warn-tabs #-}++module Text.Nowdoc (nowdoc) where++import Language.Haskell.TH (litE, stringL)+import Language.Haskell.TH.Quote (QuasiQuoter(..))++nowdoc :: QuasiQuoter+nowdoc = QuasiQuoter {+	quoteExp = litE . stringL . unescape . dropHeadNewline,+	quotePat = const . error $ errorString "a pattern",+	quoteType = const . error $ errorString "a type",+	quoteDec = const . error $ errorString "a declaration"+	}++errorString :: String -> String+errorString ctx =+	"You have used the `nowdoc' QuasiQoter in " ++ ctx +++	" context; you must only use it in an expression context"++dropHeadNewline :: String -> String+dropHeadNewline ('\n' : cs) = cs+dropHeadNewline cs = cs++unescape :: String -> String+unescape ('|' : cs) = case span (== ' ') cs of+	(_ : ss, ']' : cs') -> '|' : ss ++ "]" ++ unescape cs'+	(ss, cs') -> '|' : ss ++ unescape cs'+unescape (c : cs) = c : unescape cs+unescape "" = ""
+ test/Spec.hs view
@@ -0,0 +1,2 @@+main :: IO ()+main = putStrLn "Test suite not yet implemented"