remove some patches that are no longer used
This commit is contained in:
parent
4a8a042dd4
commit
b98fecc888
16 changed files with 1 additions and 2049 deletions
|
@ -1,227 +0,0 @@
|
|||
From 0cfdb30120976290068f4bcbebbf236b960afbb6 Mon Sep 17 00:00:00 2001
|
||||
From: dummy <dummy@example.com>
|
||||
Date: Thu, 26 Dec 2013 20:01:30 -0400
|
||||
Subject: [PATCH] hack to build
|
||||
|
||||
---
|
||||
Crypto/Number/Basic.hs | 14 --------------
|
||||
Crypto/Number/ModArithmetic.hs | 29 -----------------------------
|
||||
Crypto/Number/Prime.hs | 18 ------------------
|
||||
crypto-numbers.cabal | 2 +-
|
||||
4 files changed, 1 insertion(+), 62 deletions(-)
|
||||
|
||||
diff --git a/Crypto/Number/Basic.hs b/Crypto/Number/Basic.hs
|
||||
index 65c14b3..eaee853 100644
|
||||
--- a/Crypto/Number/Basic.hs
|
||||
+++ b/Crypto/Number/Basic.hs
|
||||
@@ -20,11 +20,7 @@ module Crypto.Number.Basic
|
||||
, areEven
|
||||
) where
|
||||
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
-import GHC.Integer.GMP.Internals
|
||||
-#else
|
||||
import Data.Bits
|
||||
-#endif
|
||||
|
||||
-- | sqrti returns two integer (l,b) so that l <= sqrt i <= b
|
||||
-- the implementation is quite naive, use an approximation for the first number
|
||||
@@ -63,25 +59,16 @@ sqrti i
|
||||
-- gcde 'a' 'b' find (x,y,gcd(a,b)) where ax + by = d
|
||||
--
|
||||
gcde :: Integer -> Integer -> (Integer, Integer, Integer)
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
-gcde a b = (s, t, g)
|
||||
- where (# g, s #) = gcdExtInteger a b
|
||||
- t = (g - s * a) `div` b
|
||||
-#else
|
||||
gcde a b = if d < 0 then (-x,-y,-d) else (x,y,d) where
|
||||
(d, x, y) = f (a,1,0) (b,0,1)
|
||||
f t (0, _, _) = t
|
||||
f (a', sa, ta) t@(b', sb, tb) =
|
||||
let (q, r) = a' `divMod` b' in
|
||||
f t (r, sa - (q * sb), ta - (q * tb))
|
||||
-#endif
|
||||
|
||||
-- | get the extended GCD of two integer using the extended binary algorithm (HAC 14.61)
|
||||
-- get (x,y,d) where d = gcd(a,b) and x,y satisfying ax + by = d
|
||||
gcde_binary :: Integer -> Integer -> (Integer, Integer, Integer)
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
-gcde_binary = gcde
|
||||
-#else
|
||||
gcde_binary a' b'
|
||||
| b' == 0 = (1,0,a')
|
||||
| a' >= b' = compute a' b'
|
||||
@@ -105,7 +92,6 @@ gcde_binary a' b'
|
||||
in if u2 >= v2
|
||||
then loop g x y (u2 - v2) v2 (a2 - c2) (b2 - d2) c2 d2
|
||||
else loop g x y u2 (v2 - u2) a2 b2 (c2 - a2) (d2 - b2)
|
||||
-#endif
|
||||
|
||||
-- | check if a list of integer are all even
|
||||
areEven :: [Integer] -> Bool
|
||||
diff --git a/Crypto/Number/ModArithmetic.hs b/Crypto/Number/ModArithmetic.hs
|
||||
index 942c12f..f8cfc32 100644
|
||||
--- a/Crypto/Number/ModArithmetic.hs
|
||||
+++ b/Crypto/Number/ModArithmetic.hs
|
||||
@@ -29,12 +29,8 @@ module Crypto.Number.ModArithmetic
|
||||
import Control.Exception (throw, Exception)
|
||||
import Data.Typeable
|
||||
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
-import GHC.Integer.GMP.Internals
|
||||
-#else
|
||||
import Crypto.Number.Basic (gcde_binary)
|
||||
import Data.Bits
|
||||
-#endif
|
||||
|
||||
-- | Raised when two numbers are supposed to be coprimes but are not.
|
||||
data CoprimesAssertionError = CoprimesAssertionError
|
||||
@@ -55,13 +51,7 @@ expSafe :: Integer -- ^ base
|
||||
-> Integer -- ^ exponant
|
||||
-> Integer -- ^ modulo
|
||||
-> Integer -- ^ result
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
-expSafe b e m
|
||||
- | odd m = powModSecInteger b e m
|
||||
- | otherwise = powModInteger b e m
|
||||
-#else
|
||||
expSafe = exponentiation
|
||||
-#endif
|
||||
|
||||
-- | Compute the modular exponentiation of base^exponant using
|
||||
-- the fastest algorithm without any consideration for
|
||||
@@ -74,11 +64,7 @@ expFast :: Integer -- ^ base
|
||||
-> Integer -- ^ modulo
|
||||
-> Integer -- ^ result
|
||||
expFast =
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
- powModInteger
|
||||
-#else
|
||||
exponentiation
|
||||
-#endif
|
||||
|
||||
-- note on exponentiation: 0^0 is treated as 1 for mimicking the standard library;
|
||||
-- the mathematic debate is still open on whether or not this is true, but pratically
|
||||
@@ -87,22 +73,15 @@ expFast =
|
||||
-- | exponentiation_rtl_binary computes modular exponentiation as b^e mod m
|
||||
-- using the right-to-left binary exponentiation algorithm (HAC 14.79)
|
||||
exponentiation_rtl_binary :: Integer -> Integer -> Integer -> Integer
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
-exponentiation_rtl_binary = expSafe
|
||||
-#else
|
||||
exponentiation_rtl_binary 0 0 m = 1 `mod` m
|
||||
exponentiation_rtl_binary b e m = loop e b 1
|
||||
where sq x = (x * x) `mod` m
|
||||
loop !0 _ !a = a `mod` m
|
||||
loop !i !s !a = loop (i `shiftR` 1) (sq s) (if odd i then a * s else a)
|
||||
-#endif
|
||||
|
||||
-- | exponentiation computes modular exponentiation as b^e mod m
|
||||
-- using repetitive squaring.
|
||||
exponentiation :: Integer -> Integer -> Integer -> Integer
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
-exponentiation = expSafe
|
||||
-#else
|
||||
exponentiation b e m
|
||||
| b == 1 = b
|
||||
| e == 0 = 1
|
||||
@@ -110,7 +89,6 @@ exponentiation b e m
|
||||
| even e = let p = (exponentiation b (e `div` 2) m) `mod` m
|
||||
in (p^(2::Integer)) `mod` m
|
||||
| otherwise = (b * exponentiation b (e-1) m) `mod` m
|
||||
-#endif
|
||||
|
||||
--{-# DEPRECATED exponantiation_rtl_binary "typo in API name it's called exponentiation_rtl_binary #-}
|
||||
exponantiation_rtl_binary :: Integer -> Integer -> Integer -> Integer
|
||||
@@ -122,17 +100,10 @@ exponantiation = exponentiation
|
||||
|
||||
-- | inverse computes the modular inverse as in g^(-1) mod m
|
||||
inverse :: Integer -> Integer -> Maybe Integer
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
-inverse g m
|
||||
- | r == 0 = Nothing
|
||||
- | otherwise = Just r
|
||||
- where r = recipModInteger g m
|
||||
-#else
|
||||
inverse g m
|
||||
| d > 1 = Nothing
|
||||
| otherwise = Just (x `mod` m)
|
||||
where (x,_,d) = gcde_binary g m
|
||||
-#endif
|
||||
|
||||
-- | Compute the modular inverse of 2 coprime numbers.
|
||||
-- This is equivalent to inverse except that the result
|
||||
diff --git a/Crypto/Number/Prime.hs b/Crypto/Number/Prime.hs
|
||||
index 0cea9da..458c94d 100644
|
||||
--- a/Crypto/Number/Prime.hs
|
||||
+++ b/Crypto/Number/Prime.hs
|
||||
@@ -3,9 +3,7 @@
|
||||
#ifndef MIN_VERSION_integer_gmp
|
||||
#define MIN_VERSION_integer_gmp(a,b,c) 0
|
||||
#endif
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
{-# LANGUAGE MagicHash #-}
|
||||
-#endif
|
||||
-- |
|
||||
-- Module : Crypto.Number.Prime
|
||||
-- License : BSD-style
|
||||
@@ -30,12 +28,7 @@ import Crypto.Number.Generate
|
||||
import Crypto.Number.Basic (sqrti, gcde_binary)
|
||||
import Crypto.Number.ModArithmetic (exponantiation)
|
||||
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
-import GHC.Integer.GMP.Internals
|
||||
-import GHC.Base
|
||||
-#else
|
||||
import Data.Bits
|
||||
-#endif
|
||||
|
||||
-- | returns if the number is probably prime.
|
||||
-- first a list of small primes are implicitely tested for divisibility,
|
||||
@@ -78,21 +71,11 @@ findPrimeFromWith rng prop !n
|
||||
-- | find a prime from a starting point with no specific property.
|
||||
findPrimeFrom :: CPRG g => g -> Integer -> (Integer, g)
|
||||
findPrimeFrom rng n =
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
- (nextPrimeInteger n, rng)
|
||||
-#else
|
||||
findPrimeFromWith rng (\g _ -> (True, g)) n
|
||||
-#endif
|
||||
|
||||
-- | Miller Rabin algorithm return if the number is probably prime or composite.
|
||||
-- the tries parameter is the number of recursion, that determines the accuracy of the test.
|
||||
primalityTestMillerRabin :: CPRG g => g -> Int -> Integer -> (Bool, g)
|
||||
-#if MIN_VERSION_integer_gmp(0,5,1)
|
||||
-primalityTestMillerRabin rng (I# tries) !n =
|
||||
- case testPrimeInteger n tries of
|
||||
- 0# -> (False, rng)
|
||||
- _ -> (True, rng)
|
||||
-#else
|
||||
primalityTestMillerRabin rng tries !n
|
||||
| n <= 3 = error "Miller-Rabin requires tested value to be > 3"
|
||||
| even n = (False, rng)
|
||||
@@ -129,7 +112,6 @@ primalityTestMillerRabin rng tries !n
|
||||
| x2 == 1 = False
|
||||
| x2 /= nm1 = loop' ws ((x2*x2) `mod` n) (r+1)
|
||||
| otherwise = loop ws
|
||||
-#endif
|
||||
|
||||
{-
|
||||
n < z -> witness to test
|
||||
diff --git a/crypto-numbers.cabal b/crypto-numbers.cabal
|
||||
index 9610e34..6669d78 100644
|
||||
--- a/crypto-numbers.cabal
|
||||
+++ b/crypto-numbers.cabal
|
||||
@@ -15,7 +15,7 @@ Extra-Source-Files: Tests/*.hs
|
||||
|
||||
Flag integer-gmp
|
||||
Description: Are we using integer-gmp?
|
||||
- Default: True
|
||||
+ Default: False
|
||||
|
||||
Library
|
||||
Build-Depends: base >= 4 && < 5
|
||||
--
|
||||
1.7.10.4
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
From afdec6c9e66211a0ac8419fffe191b059d1fd00c Mon Sep 17 00:00:00 2001
|
||||
From: foo <foo@bar>
|
||||
Date: Sun, 22 Sep 2013 17:24:33 +0000
|
||||
Subject: [PATCH] fix build with new base
|
||||
|
||||
---
|
||||
Data/Text/IDN/IDNA.chs | 1 +
|
||||
Data/Text/IDN/Punycode.chs | 1 +
|
||||
Data/Text/IDN/StringPrep.chs | 1 +
|
||||
3 files changed, 3 insertions(+)
|
||||
|
||||
diff --git a/Data/Text/IDN/IDNA.chs b/Data/Text/IDN/IDNA.chs
|
||||
index ed29ee4..dbb4ba5 100644
|
||||
--- a/Data/Text/IDN/IDNA.chs
|
||||
+++ b/Data/Text/IDN/IDNA.chs
|
||||
@@ -31,6 +31,7 @@ import Foreign
|
||||
import Foreign.C
|
||||
|
||||
import Data.Text.IDN.Internal
|
||||
+import System.IO.Unsafe
|
||||
|
||||
#include <idna.h>
|
||||
#include <idn-free.h>
|
||||
diff --git a/Data/Text/IDN/Punycode.chs b/Data/Text/IDN/Punycode.chs
|
||||
index 24b5fa6..4e62555 100644
|
||||
--- a/Data/Text/IDN/Punycode.chs
|
||||
+++ b/Data/Text/IDN/Punycode.chs
|
||||
@@ -32,6 +32,7 @@ import Data.List (unfoldr)
|
||||
import qualified Data.ByteString as B
|
||||
import qualified Data.Text as T
|
||||
|
||||
+import System.IO.Unsafe
|
||||
import Foreign
|
||||
import Foreign.C
|
||||
|
||||
diff --git a/Data/Text/IDN/StringPrep.chs b/Data/Text/IDN/StringPrep.chs
|
||||
index 752dc9e..5e9fd84 100644
|
||||
--- a/Data/Text/IDN/StringPrep.chs
|
||||
+++ b/Data/Text/IDN/StringPrep.chs
|
||||
@@ -39,6 +39,7 @@ import qualified Data.ByteString as B
|
||||
import qualified Data.Text as T
|
||||
import qualified Data.Text.Encoding as TE
|
||||
|
||||
+import System.IO.Unsafe
|
||||
import Foreign
|
||||
import Foreign.C
|
||||
|
||||
--
|
||||
1.7.10.4
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
From dca2a30ca06865bf66cd25cc14b06f5d28190231 Mon Sep 17 00:00:00 2001
|
||||
From: dummy <dummy@example.com>
|
||||
Date: Thu, 16 Oct 2014 02:46:57 +0000
|
||||
Subject: [PATCH] remove TH
|
||||
|
||||
---
|
||||
Text/Shakespeare/Text.hs | 125 +++++------------------------------------------
|
||||
1 file changed, 11 insertions(+), 114 deletions(-)
|
||||
|
||||
diff --git a/Text/Shakespeare/Text.hs b/Text/Shakespeare/Text.hs
|
||||
index 6865a5a..e25a8be 100644
|
||||
--- a/Text/Shakespeare/Text.hs
|
||||
+++ b/Text/Shakespeare/Text.hs
|
||||
@@ -7,18 +7,18 @@ module Text.Shakespeare.Text
|
||||
( TextUrl
|
||||
, ToText (..)
|
||||
, renderTextUrl
|
||||
- , stext
|
||||
- , text
|
||||
- , textFile
|
||||
- , textFileDebug
|
||||
- , textFileReload
|
||||
- , st -- | strict text
|
||||
- , lt -- | lazy text, same as stext :)
|
||||
+ --, stext
|
||||
+ --, text
|
||||
+ --, textFile
|
||||
+ --, textFileDebug
|
||||
+ --, textFileReload
|
||||
+ --, st -- | strict text
|
||||
+ --, lt -- | lazy text, same as stext :)
|
||||
-- * Yesod code generation
|
||||
- , codegen
|
||||
- , codegenSt
|
||||
- , codegenFile
|
||||
- , codegenFileReload
|
||||
+ --, codegen
|
||||
+ --, codegenSt
|
||||
+ --, codegenFile
|
||||
+ --, codegenFileReload
|
||||
) where
|
||||
|
||||
import Language.Haskell.TH.Quote (QuasiQuoter (..))
|
||||
@@ -45,106 +45,3 @@ instance ToText Int32 where toText = toText . show
|
||||
instance ToText Int64 where toText = toText . show
|
||||
instance ToText Int where toText = toText . show
|
||||
|
||||
-settings :: Q ShakespeareSettings
|
||||
-settings = do
|
||||
- toTExp <- [|toText|]
|
||||
- wrapExp <- [|id|]
|
||||
- unWrapExp <- [|id|]
|
||||
- return $ defaultShakespeareSettings { toBuilder = toTExp
|
||||
- , wrap = wrapExp
|
||||
- , unwrap = unWrapExp
|
||||
- }
|
||||
-
|
||||
-
|
||||
-stext, lt, st, text :: QuasiQuoter
|
||||
-stext =
|
||||
- QuasiQuoter { quoteExp = \s -> do
|
||||
- rs <- settings
|
||||
- render <- [|toLazyText|]
|
||||
- rendered <- shakespeareFromString rs { justVarInterpolation = True } s
|
||||
- return (render `AppE` rendered)
|
||||
- }
|
||||
-lt = stext
|
||||
-
|
||||
-st =
|
||||
- QuasiQuoter { quoteExp = \s -> do
|
||||
- rs <- settings
|
||||
- render <- [|TL.toStrict . toLazyText|]
|
||||
- rendered <- shakespeareFromString rs { justVarInterpolation = True } s
|
||||
- return (render `AppE` rendered)
|
||||
- }
|
||||
-
|
||||
-text = QuasiQuoter { quoteExp = \s -> do
|
||||
- rs <- settings
|
||||
- quoteExp (shakespeare rs) $ filter (/='\r') s
|
||||
- }
|
||||
-
|
||||
-
|
||||
-textFile :: FilePath -> Q Exp
|
||||
-textFile fp = do
|
||||
- rs <- settings
|
||||
- shakespeareFile rs fp
|
||||
-
|
||||
-
|
||||
-textFileDebug :: FilePath -> Q Exp
|
||||
-textFileDebug = textFileReload
|
||||
-{-# DEPRECATED textFileDebug "Please use textFileReload instead" #-}
|
||||
-
|
||||
-textFileReload :: FilePath -> Q Exp
|
||||
-textFileReload fp = do
|
||||
- rs <- settings
|
||||
- shakespeareFileReload rs fp
|
||||
-
|
||||
--- | codegen is designed for generating Yesod code, including templates
|
||||
--- So it uses different interpolation characters that won't clash with templates.
|
||||
-codegenSettings :: Q ShakespeareSettings
|
||||
-codegenSettings = do
|
||||
- toTExp <- [|toText|]
|
||||
- wrapExp <- [|id|]
|
||||
- unWrapExp <- [|id|]
|
||||
- return $ defaultShakespeareSettings { toBuilder = toTExp
|
||||
- , wrap = wrapExp
|
||||
- , unwrap = unWrapExp
|
||||
- , varChar = '~'
|
||||
- , urlChar = '*'
|
||||
- , intChar = '&'
|
||||
- , justVarInterpolation = True -- always!
|
||||
- }
|
||||
-
|
||||
--- | codegen is designed for generating Yesod code, including templates
|
||||
--- So it uses different interpolation characters that won't clash with templates.
|
||||
--- You can use the normal text quasiquoters to generate code
|
||||
-codegen :: QuasiQuoter
|
||||
-codegen =
|
||||
- QuasiQuoter { quoteExp = \s -> do
|
||||
- rs <- codegenSettings
|
||||
- render <- [|toLazyText|]
|
||||
- rendered <- shakespeareFromString rs { justVarInterpolation = True } s
|
||||
- return (render `AppE` rendered)
|
||||
- }
|
||||
-
|
||||
--- | Generates strict Text
|
||||
--- codegen is designed for generating Yesod code, including templates
|
||||
--- So it uses different interpolation characters that won't clash with templates.
|
||||
-codegenSt :: QuasiQuoter
|
||||
-codegenSt =
|
||||
- QuasiQuoter { quoteExp = \s -> do
|
||||
- rs <- codegenSettings
|
||||
- render <- [|TL.toStrict . toLazyText|]
|
||||
- rendered <- shakespeareFromString rs { justVarInterpolation = True } s
|
||||
- return (render `AppE` rendered)
|
||||
- }
|
||||
-
|
||||
-codegenFileReload :: FilePath -> Q Exp
|
||||
-codegenFileReload fp = do
|
||||
- rs <- codegenSettings
|
||||
- render <- [|TL.toStrict . toLazyText|]
|
||||
- rendered <- shakespeareFileReload rs{ justVarInterpolation = True } fp
|
||||
- return (render `AppE` rendered)
|
||||
-
|
||||
-codegenFile :: FilePath -> Q Exp
|
||||
-codegenFile fp = do
|
||||
- rs <- codegenSettings
|
||||
- render <- [|TL.toStrict . toLazyText|]
|
||||
- rendered <- shakespeareFile rs{ justVarInterpolation = True } fp
|
||||
- return (render `AppE` rendered)
|
||||
--
|
||||
2.1.1
|
||||
|
|
@ -97,19 +97,14 @@ EOF
|
|||
patched persistent-template
|
||||
patched system-filepath
|
||||
patched optparse-applicative
|
||||
patched warp
|
||||
patched wai-app-static
|
||||
patched shakespeare
|
||||
patched shakespeare-css
|
||||
patched shakespeare-js
|
||||
patched yesod-routes
|
||||
patched yesod-core
|
||||
patched yesod-persistent
|
||||
patched yesod-form
|
||||
patched crypto-numbers
|
||||
patched clock
|
||||
patched yesod-auth
|
||||
patched yesod
|
||||
patched shakespeare-text
|
||||
patched process-conduit
|
||||
patched DAV
|
||||
patched yesod-static
|
||||
|
@ -117,7 +112,6 @@ EOF
|
|||
patched dns
|
||||
patched gnutls
|
||||
patched unbounded-delays
|
||||
patched gnuidn
|
||||
patched network-protocol-xmpp
|
||||
|
||||
cd ..
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
From f147ec9aeaa03ca6e30232c84c413ef29b95fb62 Mon Sep 17 00:00:00 2001
|
||||
From: Your Name <you@example.com>
|
||||
Date: Tue, 20 May 2014 19:53:55 +0000
|
||||
Subject: [PATCH] avoid TH
|
||||
|
||||
---
|
||||
aeson.cabal | 3 ---
|
||||
1 file changed, 3 deletions(-)
|
||||
|
||||
diff --git a/aeson.cabal b/aeson.cabal
|
||||
index 493d625..02dc6f4 100644
|
||||
--- a/aeson.cabal
|
||||
+++ b/aeson.cabal
|
||||
@@ -88,7 +88,6 @@ library
|
||||
Data.Aeson.Generic
|
||||
Data.Aeson.Parser
|
||||
Data.Aeson.Types
|
||||
- Data.Aeson.TH
|
||||
|
||||
other-modules:
|
||||
Data.Aeson.Functions
|
||||
@@ -121,7 +120,6 @@ library
|
||||
old-locale,
|
||||
scientific >= 0.3.1 && < 0.4,
|
||||
syb,
|
||||
- template-haskell >= 2.4,
|
||||
time,
|
||||
unordered-containers >= 0.2.3.0,
|
||||
vector >= 0.7.1
|
||||
@@ -164,7 +162,6 @@ test-suite tests
|
||||
base,
|
||||
containers,
|
||||
bytestring,
|
||||
- template-haskell,
|
||||
test-framework,
|
||||
test-framework-quickcheck2,
|
||||
test-framework-hunit,
|
||||
--
|
||||
2.0.0.rc2
|
||||
|
|
@ -1,132 +0,0 @@
|
|||
From 497d09a91f9eb1e5979948cd128078491b0e8bca Mon Sep 17 00:00:00 2001
|
||||
From: Joey Hess <joey@kitenet.net>
|
||||
Date: Fri, 12 Sep 2014 20:52:08 -0400
|
||||
Subject: [PATCH] remove TH
|
||||
|
||||
---
|
||||
Data/FileEmbed.hs | 87 ++++---------------------------------------------------
|
||||
1 file changed, 5 insertions(+), 82 deletions(-)
|
||||
|
||||
diff --git a/Data/FileEmbed.hs b/Data/FileEmbed.hs
|
||||
index 5617493..adacdba 100644
|
||||
--- a/Data/FileEmbed.hs
|
||||
+++ b/Data/FileEmbed.hs
|
||||
@@ -17,13 +17,13 @@
|
||||
-- > {-# LANGUAGE TemplateHaskell #-}
|
||||
module Data.FileEmbed
|
||||
( -- * Embed at compile time
|
||||
- embedFile
|
||||
- , embedOneFileOf
|
||||
- , embedDir
|
||||
- , getDir
|
||||
+ -- embedFile
|
||||
+ --, embedOneFileOf
|
||||
+ --, embedDir
|
||||
+ getDir
|
||||
-- * Inject into an executable
|
||||
#if MIN_VERSION_template_haskell(2,5,0)
|
||||
- , dummySpace
|
||||
+ --, dummySpace
|
||||
#endif
|
||||
, inject
|
||||
, injectFile
|
||||
@@ -56,73 +56,12 @@ import Data.ByteString.Unsafe (unsafePackAddressLen)
|
||||
import System.IO.Unsafe (unsafePerformIO)
|
||||
import System.FilePath ((</>))
|
||||
|
||||
--- | Embed a single file in your source code.
|
||||
---
|
||||
--- > import qualified Data.ByteString
|
||||
--- >
|
||||
--- > myFile :: Data.ByteString.ByteString
|
||||
--- > myFile = $(embedFile "dirName/fileName")
|
||||
-embedFile :: FilePath -> Q Exp
|
||||
-embedFile fp =
|
||||
-#if MIN_VERSION_template_haskell(2,7,0)
|
||||
- qAddDependentFile fp >>
|
||||
-#endif
|
||||
- (runIO $ B.readFile fp) >>= bsToExp
|
||||
-
|
||||
--- | Embed a single existing file in your source code
|
||||
--- out of list a list of paths supplied.
|
||||
---
|
||||
--- > import qualified Data.ByteString
|
||||
--- >
|
||||
--- > myFile :: Data.ByteString.ByteString
|
||||
--- > myFile = $(embedFile' [ "dirName/fileName", "src/dirName/fileName" ])
|
||||
-embedOneFileOf :: [FilePath] -> Q Exp
|
||||
-embedOneFileOf ps =
|
||||
- (runIO $ readExistingFile ps) >>= \ ( path, content ) -> do
|
||||
-#if MIN_VERSION_template_haskell(2,7,0)
|
||||
- qAddDependentFile path
|
||||
-#endif
|
||||
- bsToExp content
|
||||
- where
|
||||
- readExistingFile :: [FilePath] -> IO ( FilePath, B.ByteString )
|
||||
- readExistingFile xs = do
|
||||
- ys <- filterM doesFileExist xs
|
||||
- case ys of
|
||||
- (p:_) -> B.readFile p >>= \ c -> return ( p, c )
|
||||
- _ -> throw $ ErrorCall "Cannot find file to embed as resource"
|
||||
-
|
||||
--- | Embed a directory recursively in your source code.
|
||||
---
|
||||
--- > import qualified Data.ByteString
|
||||
--- >
|
||||
--- > myDir :: [(FilePath, Data.ByteString.ByteString)]
|
||||
--- > myDir = $(embedDir "dirName")
|
||||
-embedDir :: FilePath -> Q Exp
|
||||
-embedDir fp = do
|
||||
- typ <- [t| [(FilePath, B.ByteString)] |]
|
||||
- e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
|
||||
- return $ SigE e typ
|
||||
-
|
||||
-- | Get a directory tree in the IO monad.
|
||||
--
|
||||
-- This is the workhorse of 'embedDir'
|
||||
getDir :: FilePath -> IO [(FilePath, B.ByteString)]
|
||||
getDir = fileList
|
||||
|
||||
-pairToExp :: FilePath -> (FilePath, B.ByteString) -> Q Exp
|
||||
-pairToExp _root (path, bs) = do
|
||||
-#if MIN_VERSION_template_haskell(2,7,0)
|
||||
- qAddDependentFile $ _root ++ '/' : path
|
||||
-#endif
|
||||
- exp' <- bsToExp bs
|
||||
- return $! TupE [LitE $ StringL path, exp']
|
||||
-
|
||||
-bsToExp :: B.ByteString -> Q Exp
|
||||
-bsToExp bs = do
|
||||
- helper <- [| stringToBs |]
|
||||
- let chars = B8.unpack bs
|
||||
- return $! AppE helper $! LitE $! StringL chars
|
||||
-
|
||||
stringToBs :: String -> B.ByteString
|
||||
stringToBs = B8.pack
|
||||
|
||||
@@ -164,22 +103,6 @@ padSize i =
|
||||
let s = show i
|
||||
in replicate (sizeLen - length s) '0' ++ s
|
||||
|
||||
-#if MIN_VERSION_template_haskell(2,5,0)
|
||||
-dummySpace :: Int -> Q Exp
|
||||
-dummySpace space = do
|
||||
- let size = padSize space
|
||||
- let start = magic ++ size
|
||||
- let chars = LitE $ StringPrimL $
|
||||
-#if MIN_VERSION_template_haskell(2,6,0)
|
||||
- map (toEnum . fromEnum) $
|
||||
-#endif
|
||||
- start ++ replicate space '0'
|
||||
- let len = LitE $ IntegerL $ fromIntegral $ length start + space
|
||||
- upi <- [|unsafePerformIO|]
|
||||
- pack <- [|unsafePackAddressLen|]
|
||||
- getInner' <- [|getInner|]
|
||||
- return $ getInner' `AppE` (upi `AppE` (pack `AppE` len `AppE` chars))
|
||||
-#endif
|
||||
|
||||
inject :: B.ByteString -- ^ bs to inject
|
||||
-> B.ByteString -- ^ original BS containing dummy
|
||||
--
|
||||
2.1.0
|
||||
|
|
@ -1,394 +0,0 @@
|
|||
From 9a41401d903f160e11d56fff35c24eb59d97885d Mon Sep 17 00:00:00 2001
|
||||
From: Joey Hess <joey@kitenet.net>
|
||||
Date: Tue, 17 Dec 2013 19:04:40 +0000
|
||||
Subject: [PATCH] remove TH
|
||||
|
||||
---
|
||||
src/Generics/Deriving/TH.hs | 354 --------------------------------------------
|
||||
1 file changed, 354 deletions(-)
|
||||
|
||||
diff --git a/src/Generics/Deriving/TH.hs b/src/Generics/Deriving/TH.hs
|
||||
index 783cb65..9aab713 100644
|
||||
--- a/src/Generics/Deriving/TH.hs
|
||||
+++ b/src/Generics/Deriving/TH.hs
|
||||
@@ -19,18 +19,6 @@
|
||||
|
||||
-- Adapted from Generics.Regular.TH
|
||||
module Generics.Deriving.TH (
|
||||
-
|
||||
- deriveMeta
|
||||
- , deriveData
|
||||
- , deriveConstructors
|
||||
- , deriveSelectors
|
||||
-
|
||||
-#if __GLASGOW_HASKELL__ < 701
|
||||
- , deriveAll
|
||||
- , deriveRepresentable0
|
||||
- , deriveRep0
|
||||
- , simplInstance
|
||||
-#endif
|
||||
) where
|
||||
|
||||
import Generics.Deriving.Base
|
||||
@@ -41,124 +29,6 @@ import Language.Haskell.TH.Syntax (Lift(..))
|
||||
import Data.List (intercalate)
|
||||
import Control.Monad
|
||||
|
||||
--- | Given the names of a generic class, a type to instantiate, a function in
|
||||
--- the class and the default implementation, generates the code for a basic
|
||||
--- generic instance.
|
||||
-simplInstance :: Name -> Name -> Name -> Name -> Q [Dec]
|
||||
-simplInstance cl ty fn df = do
|
||||
- i <- reify (genRepName 0 ty)
|
||||
- x <- newName "x"
|
||||
- let typ = ForallT [PlainTV x] []
|
||||
- ((foldl (\a -> AppT a . VarT . tyVarBndrToName) (ConT (genRepName 0 ty))
|
||||
- (typeVariables i)) `AppT` (VarT x))
|
||||
- fmap (: []) $ instanceD (cxt []) (conT cl `appT` conT ty)
|
||||
- [funD fn [clause [] (normalB (varE df `appE`
|
||||
- (sigE (global 'undefined) (return typ)))) []]]
|
||||
-
|
||||
-
|
||||
--- | Given the type and the name (as string) for the type to derive,
|
||||
--- generate the 'Data' instance, the 'Constructor' instances, the 'Selector'
|
||||
--- instances, and the 'Representable0' instance.
|
||||
-deriveAll :: Name -> Q [Dec]
|
||||
-deriveAll n =
|
||||
- do a <- deriveMeta n
|
||||
- b <- deriveRepresentable0 n
|
||||
- return (a ++ b)
|
||||
-
|
||||
--- | Given the type and the name (as string) for the type to derive,
|
||||
--- generate the 'Data' instance, the 'Constructor' instances, and the 'Selector'
|
||||
--- instances.
|
||||
-deriveMeta :: Name -> Q [Dec]
|
||||
-deriveMeta n =
|
||||
- do a <- deriveData n
|
||||
- b <- deriveConstructors n
|
||||
- c <- deriveSelectors n
|
||||
- return (a ++ b ++ c)
|
||||
-
|
||||
--- | Given a datatype name, derive a datatype and instance of class 'Datatype'.
|
||||
-deriveData :: Name -> Q [Dec]
|
||||
-deriveData = dataInstance
|
||||
-
|
||||
--- | Given a datatype name, derive datatypes and
|
||||
--- instances of class 'Constructor'.
|
||||
-deriveConstructors :: Name -> Q [Dec]
|
||||
-deriveConstructors = constrInstance
|
||||
-
|
||||
--- | Given a datatype name, derive datatypes and instances of class 'Selector'.
|
||||
-deriveSelectors :: Name -> Q [Dec]
|
||||
-deriveSelectors = selectInstance
|
||||
-
|
||||
--- | Given the type and the name (as string) for the Representable0 type
|
||||
--- synonym to derive, generate the 'Representable0' instance.
|
||||
-deriveRepresentable0 :: Name -> Q [Dec]
|
||||
-deriveRepresentable0 n = do
|
||||
- rep0 <- deriveRep0 n
|
||||
- inst <- deriveInst n
|
||||
- return $ rep0 ++ inst
|
||||
-
|
||||
--- | Derive only the 'Rep0' type synonym. Not needed if 'deriveRepresentable0'
|
||||
--- is used.
|
||||
-deriveRep0 :: Name -> Q [Dec]
|
||||
-deriveRep0 n = do
|
||||
- i <- reify n
|
||||
- fmap (:[]) $ tySynD (genRepName 0 n) (typeVariables i) (rep0Type n)
|
||||
-
|
||||
-deriveInst :: Name -> Q [Dec]
|
||||
-deriveInst t = do
|
||||
- i <- reify t
|
||||
- let typ q = foldl (\a -> AppT a . VarT . tyVarBndrToName) (ConT q)
|
||||
- (typeVariables i)
|
||||
-#if __GLASGOW_HASKELL__ >= 707
|
||||
- let tyIns = TySynInstD ''Rep (TySynEqn [typ t] (typ (genRepName 0 t)))
|
||||
-#else
|
||||
- let tyIns = TySynInstD ''Rep [typ t] (typ (genRepName 0 t))
|
||||
-#endif
|
||||
- fcs <- mkFrom t 1 0 t
|
||||
- tcs <- mkTo t 1 0 t
|
||||
- liftM (:[]) $
|
||||
- instanceD (cxt []) (conT ''Generic `appT` return (typ t))
|
||||
- [return tyIns, funD 'from fcs, funD 'to tcs]
|
||||
-
|
||||
-
|
||||
-dataInstance :: Name -> Q [Dec]
|
||||
-dataInstance n = do
|
||||
- i <- reify n
|
||||
- case i of
|
||||
- TyConI (DataD _ n _ _ _) -> mkInstance n
|
||||
- TyConI (NewtypeD _ n _ _ _) -> mkInstance n
|
||||
- _ -> return []
|
||||
- where
|
||||
- mkInstance n = do
|
||||
- ds <- mkDataData n
|
||||
- is <- mkDataInstance n
|
||||
- return $ [ds,is]
|
||||
-
|
||||
-constrInstance :: Name -> Q [Dec]
|
||||
-constrInstance n = do
|
||||
- i <- reify n
|
||||
- case i of
|
||||
- TyConI (DataD _ n _ cs _) -> mkInstance n cs
|
||||
- TyConI (NewtypeD _ n _ c _) -> mkInstance n [c]
|
||||
- _ -> return []
|
||||
- where
|
||||
- mkInstance n cs = do
|
||||
- ds <- mapM (mkConstrData n) cs
|
||||
- is <- mapM (mkConstrInstance n) cs
|
||||
- return $ ds ++ is
|
||||
-
|
||||
-selectInstance :: Name -> Q [Dec]
|
||||
-selectInstance n = do
|
||||
- i <- reify n
|
||||
- case i of
|
||||
- TyConI (DataD _ n _ cs _) -> mkInstance n cs
|
||||
- TyConI (NewtypeD _ n _ c _) -> mkInstance n [c]
|
||||
- _ -> return []
|
||||
- where
|
||||
- mkInstance n cs = do
|
||||
- ds <- mapM (mkSelectData n) cs
|
||||
- is <- mapM (mkSelectInstance n) cs
|
||||
- return $ concat (ds ++ is)
|
||||
-
|
||||
typeVariables :: Info -> [TyVarBndr]
|
||||
typeVariables (TyConI (DataD _ _ tv _ _)) = tv
|
||||
typeVariables (TyConI (NewtypeD _ _ tv _ _)) = tv
|
||||
@@ -179,233 +49,9 @@ genName = mkName . (++"_") . intercalate "_" . map nameBase
|
||||
genRepName :: Int -> Name -> Name
|
||||
genRepName n = mkName . (++"_") . (("Rep" ++ show n) ++) . nameBase
|
||||
|
||||
-mkDataData :: Name -> Q Dec
|
||||
-mkDataData n = dataD (cxt []) (genName [n]) [] [] []
|
||||
-
|
||||
-mkConstrData :: Name -> Con -> Q Dec
|
||||
-mkConstrData dt (NormalC n _) =
|
||||
- dataD (cxt []) (genName [dt, n]) [] [] []
|
||||
-mkConstrData dt r@(RecC _ _) =
|
||||
- mkConstrData dt (stripRecordNames r)
|
||||
-mkConstrData dt (InfixC t1 n t2) =
|
||||
- mkConstrData dt (NormalC n [t1,t2])
|
||||
-
|
||||
-mkSelectData :: Name -> Con -> Q [Dec]
|
||||
-mkSelectData dt r@(RecC n fs) = return (map one fs)
|
||||
- where one (f, _, _) = DataD [] (genName [dt, n, f]) [] [] []
|
||||
-mkSelectData dt _ = return []
|
||||
-
|
||||
-
|
||||
-mkDataInstance :: Name -> Q Dec
|
||||
-mkDataInstance n =
|
||||
- instanceD (cxt []) (appT (conT ''Datatype) (conT $ genName [n]))
|
||||
- [funD 'datatypeName [clause [wildP] (normalB (stringE (nameBase n))) []]
|
||||
- ,funD 'moduleName [clause [wildP] (normalB (stringE name)) []]]
|
||||
- where
|
||||
- name = maybe (error "Cannot fetch module name!") id (nameModule n)
|
||||
-
|
||||
-instance Lift Fixity where
|
||||
- lift Prefix = conE 'Prefix
|
||||
- lift (Infix a n) = conE 'Infix `appE` [| a |] `appE` [| n |]
|
||||
-
|
||||
-instance Lift Associativity where
|
||||
- lift LeftAssociative = conE 'LeftAssociative
|
||||
- lift RightAssociative = conE 'RightAssociative
|
||||
- lift NotAssociative = conE 'NotAssociative
|
||||
-
|
||||
-mkConstrInstance :: Name -> Con -> Q Dec
|
||||
-mkConstrInstance dt (NormalC n _) = mkConstrInstanceWith dt n []
|
||||
-mkConstrInstance dt (RecC n _) = mkConstrInstanceWith dt n
|
||||
- [ funD 'conIsRecord [clause [wildP] (normalB (conE 'True)) []]]
|
||||
-mkConstrInstance dt (InfixC t1 n t2) =
|
||||
- do
|
||||
- i <- reify n
|
||||
- let fi = case i of
|
||||
- DataConI _ _ _ f -> convertFixity f
|
||||
- _ -> Prefix
|
||||
- instanceD (cxt []) (appT (conT ''Constructor) (conT $ genName [dt, n]))
|
||||
- [funD 'conName [clause [wildP] (normalB (stringE (nameBase n))) []],
|
||||
- funD 'conFixity [clause [wildP] (normalB [| fi |]) []]]
|
||||
- where
|
||||
- convertFixity (Fixity n d) = Infix (convertDirection d) n
|
||||
- convertDirection InfixL = LeftAssociative
|
||||
- convertDirection InfixR = RightAssociative
|
||||
- convertDirection InfixN = NotAssociative
|
||||
-
|
||||
-mkConstrInstanceWith :: Name -> Name -> [Q Dec] -> Q Dec
|
||||
-mkConstrInstanceWith dt n extra =
|
||||
- instanceD (cxt []) (appT (conT ''Constructor) (conT $ genName [dt, n]))
|
||||
- (funD 'conName [clause [wildP] (normalB (stringE (nameBase n))) []] : extra)
|
||||
-
|
||||
-mkSelectInstance :: Name -> Con -> Q [Dec]
|
||||
-mkSelectInstance dt r@(RecC n fs) = return (map one fs) where
|
||||
- one (f, _, _) =
|
||||
- InstanceD ([]) (AppT (ConT ''Selector) (ConT $ genName [dt, n, f]))
|
||||
- [FunD 'selName [Clause [WildP]
|
||||
- (NormalB (LitE (StringL (nameBase f)))) []]]
|
||||
-mkSelectInstance _ _ = return []
|
||||
-
|
||||
-rep0Type :: Name -> Q Type
|
||||
-rep0Type n =
|
||||
- do
|
||||
- -- runIO $ putStrLn $ "processing " ++ show n
|
||||
- i <- reify n
|
||||
- let b = case i of
|
||||
- TyConI (DataD _ dt vs cs _) ->
|
||||
- (conT ''D1) `appT` (conT $ genName [dt]) `appT`
|
||||
- (foldr1' sum (conT ''V1)
|
||||
- (map (rep0Con (dt, map tyVarBndrToName vs)) cs))
|
||||
- TyConI (NewtypeD _ dt vs c _) ->
|
||||
- (conT ''D1) `appT` (conT $ genName [dt]) `appT`
|
||||
- (rep0Con (dt, map tyVarBndrToName vs) c)
|
||||
- TyConI (TySynD t _ _) -> error "type synonym?"
|
||||
- _ -> error "unknown construct"
|
||||
- --appT b (conT $ mkName (nameBase n))
|
||||
- b where
|
||||
- sum :: Q Type -> Q Type -> Q Type
|
||||
- sum a b = conT ''(:+:) `appT` a `appT` b
|
||||
-
|
||||
-
|
||||
-rep0Con :: (Name, [Name]) -> Con -> Q Type
|
||||
-rep0Con (dt, vs) (NormalC n []) =
|
||||
- conT ''C1 `appT` (conT $ genName [dt, n]) `appT`
|
||||
- (conT ''S1 `appT` conT ''NoSelector `appT` conT ''U1)
|
||||
-rep0Con (dt, vs) (NormalC n fs) =
|
||||
- conT ''C1 `appT` (conT $ genName [dt, n]) `appT`
|
||||
- (foldr1 prod (map (repField (dt, vs) . snd) fs)) where
|
||||
- prod :: Q Type -> Q Type -> Q Type
|
||||
- prod a b = conT ''(:*:) `appT` a `appT` b
|
||||
-rep0Con (dt, vs) r@(RecC n []) =
|
||||
- conT ''C1 `appT` (conT $ genName [dt, n]) `appT` conT ''U1
|
||||
-rep0Con (dt, vs) r@(RecC n fs) =
|
||||
- conT ''C1 `appT` (conT $ genName [dt, n]) `appT`
|
||||
- (foldr1 prod (map (repField' (dt, vs) n) fs)) where
|
||||
- prod :: Q Type -> Q Type -> Q Type
|
||||
- prod a b = conT ''(:*:) `appT` a `appT` b
|
||||
-
|
||||
-rep0Con d (InfixC t1 n t2) = rep0Con d (NormalC n [t1,t2])
|
||||
-
|
||||
---dataDeclToType :: (Name, [Name]) -> Type
|
||||
---dataDeclToType (dt, vs) = foldl (\a b -> AppT a (VarT b)) (ConT dt) vs
|
||||
-
|
||||
-repField :: (Name, [Name]) -> Type -> Q Type
|
||||
---repField d t | t == dataDeclToType d = conT ''I
|
||||
-repField d t = conT ''S1 `appT` conT ''NoSelector `appT`
|
||||
- (conT ''Rec0 `appT` return t)
|
||||
-
|
||||
-repField' :: (Name, [Name]) -> Name -> (Name, Strict, Type) -> Q Type
|
||||
---repField' d ns (_, _, t) | t == dataDeclToType d = conT ''I
|
||||
-repField' (dt, vs) ns (f, _, t) = conT ''S1 `appT` conT (genName [dt, ns, f])
|
||||
- `appT` (conT ''Rec0 `appT` return t)
|
||||
--- Note: we should generate Par0 too, at some point
|
||||
-
|
||||
-
|
||||
-mkFrom :: Name -> Int -> Int -> Name -> Q [Q Clause]
|
||||
-mkFrom ns m i n =
|
||||
- do
|
||||
- -- runIO $ putStrLn $ "processing " ++ show n
|
||||
- let wrapE e = lrE m i e
|
||||
- i <- reify n
|
||||
- let b = case i of
|
||||
- TyConI (DataD _ dt vs cs _) ->
|
||||
- zipWith (fromCon wrapE ns (dt, map tyVarBndrToName vs)
|
||||
- (length cs)) [0..] cs
|
||||
- TyConI (NewtypeD _ dt vs c _) ->
|
||||
- [fromCon wrapE ns (dt, map tyVarBndrToName vs) 1 0 c]
|
||||
- TyConI (TySynD t _ _) -> error "type synonym?"
|
||||
- -- [clause [varP (field 0)] (normalB (wrapE $ conE 'K1 `appE` varE (field 0))) []]
|
||||
- _ -> error "unknown construct"
|
||||
- return b
|
||||
-
|
||||
-mkTo :: Name -> Int -> Int -> Name -> Q [Q Clause]
|
||||
-mkTo ns m i n =
|
||||
- do
|
||||
- -- runIO $ putStrLn $ "processing " ++ show n
|
||||
- let wrapP p = lrP m i p
|
||||
- i <- reify n
|
||||
- let b = case i of
|
||||
- TyConI (DataD _ dt vs cs _) ->
|
||||
- zipWith (toCon wrapP ns (dt, map tyVarBndrToName vs)
|
||||
- (length cs)) [0..] cs
|
||||
- TyConI (NewtypeD _ dt vs c _) ->
|
||||
- [toCon wrapP ns (dt, map tyVarBndrToName vs) 1 0 c]
|
||||
- TyConI (TySynD t _ _) -> error "type synonym?"
|
||||
- -- [clause [wrapP $ conP 'K1 [varP (field 0)]] (normalB $ varE (field 0)) []]
|
||||
- _ -> error "unknown construct"
|
||||
- return b
|
||||
-
|
||||
-fromCon :: (Q Exp -> Q Exp) -> Name -> (Name, [Name]) -> Int -> Int -> Con -> Q Clause
|
||||
-fromCon wrap ns (dt, vs) m i (NormalC cn []) =
|
||||
- clause
|
||||
- [conP cn []]
|
||||
- (normalB $ appE (conE 'M1) $ wrap $ lrE m i $ appE (conE 'M1) $
|
||||
- conE 'M1 `appE` (conE 'U1)) []
|
||||
-fromCon wrap ns (dt, vs) m i (NormalC cn fs) =
|
||||
- -- runIO (putStrLn ("constructor " ++ show ix)) >>
|
||||
- clause
|
||||
- [conP cn (map (varP . field) [0..length fs - 1])]
|
||||
- (normalB $ appE (conE 'M1) $ wrap $ lrE m i $ conE 'M1 `appE`
|
||||
- foldr1 prod (zipWith (fromField (dt, vs)) [0..] (map snd fs))) []
|
||||
- where prod x y = conE '(:*:) `appE` x `appE` y
|
||||
-fromCon wrap ns (dt, vs) m i r@(RecC cn []) =
|
||||
- clause
|
||||
- [conP cn []]
|
||||
- (normalB $ appE (conE 'M1) $ wrap $ lrE m i $ conE 'M1 `appE` (conE 'U1)) []
|
||||
-fromCon wrap ns (dt, vs) m i r@(RecC cn fs) =
|
||||
- clause
|
||||
- [conP cn (map (varP . field) [0..length fs - 1])]
|
||||
- (normalB $ appE (conE 'M1) $ wrap $ lrE m i $ conE 'M1 `appE`
|
||||
- foldr1 prod (zipWith (fromField (dt, vs)) [0..] (map trd fs))) []
|
||||
- where prod x y = conE '(:*:) `appE` x `appE` y
|
||||
-fromCon wrap ns (dt, vs) m i (InfixC t1 cn t2) =
|
||||
- fromCon wrap ns (dt, vs) m i (NormalC cn [t1,t2])
|
||||
-
|
||||
-fromField :: (Name, [Name]) -> Int -> Type -> Q Exp
|
||||
---fromField (dt, vs) nr t | t == dataDeclToType (dt, vs) = conE 'I `appE` varE (field nr)
|
||||
-fromField (dt, vs) nr t = conE 'M1 `appE` (conE 'K1 `appE` varE (field nr))
|
||||
-
|
||||
-toCon :: (Q Pat -> Q Pat) -> Name -> (Name, [Name]) -> Int -> Int -> Con -> Q Clause
|
||||
-toCon wrap ns (dt, vs) m i (NormalC cn []) =
|
||||
- clause
|
||||
- [wrap $ conP 'M1 [lrP m i $ conP 'M1 [conP 'M1 [conP 'U1 []]]]]
|
||||
- (normalB $ conE cn) []
|
||||
-toCon wrap ns (dt, vs) m i (NormalC cn fs) =
|
||||
- -- runIO (putStrLn ("constructor " ++ show ix)) >>
|
||||
- clause
|
||||
- [wrap $ conP 'M1 [lrP m i $ conP 'M1
|
||||
- [foldr1 prod (zipWith (toField (dt, vs)) [0..] (map snd fs))]]]
|
||||
- (normalB $ foldl appE (conE cn) (map (varE . field) [0..length fs - 1])) []
|
||||
- where prod x y = conP '(:*:) [x,y]
|
||||
-toCon wrap ns (dt, vs) m i r@(RecC cn []) =
|
||||
- clause
|
||||
- [wrap $ conP 'M1 [lrP m i $ conP 'M1 [conP 'U1 []]]]
|
||||
- (normalB $ conE cn) []
|
||||
-toCon wrap ns (dt, vs) m i r@(RecC cn fs) =
|
||||
- clause
|
||||
- [wrap $ conP 'M1 [lrP m i $ conP 'M1
|
||||
- [foldr1 prod (zipWith (toField (dt, vs)) [0..] (map trd fs))]]]
|
||||
- (normalB $ foldl appE (conE cn) (map (varE . field) [0..length fs - 1])) []
|
||||
- where prod x y = conP '(:*:) [x,y]
|
||||
-toCon wrap ns (dt, vs) m i (InfixC t1 cn t2) =
|
||||
- toCon wrap ns (dt, vs) m i (NormalC cn [t1,t2])
|
||||
-
|
||||
-toField :: (Name, [Name]) -> Int -> Type -> Q Pat
|
||||
---toField (dt, vs) nr t | t == dataDeclToType (dt, vs) = conP 'I [varP (field nr)]
|
||||
-toField (dt, vs) nr t = conP 'M1 [conP 'K1 [varP (field nr)]]
|
||||
-
|
||||
-
|
||||
field :: Int -> Name
|
||||
field n = mkName $ "f" ++ show n
|
||||
|
||||
-lrP :: Int -> Int -> (Q Pat -> Q Pat)
|
||||
-lrP 1 0 p = p
|
||||
-lrP m 0 p = conP 'L1 [p]
|
||||
-lrP m i p = conP 'R1 [lrP (m-1) (i-1) p]
|
||||
-
|
||||
-lrE :: Int -> Int -> (Q Exp -> Q Exp)
|
||||
-lrE 1 0 e = e
|
||||
-lrE m 0 e = conE 'L1 `appE` e
|
||||
-lrE m i e = conE 'R1 `appE` lrE (m-1) (i-1) e
|
||||
|
||||
trd (_,_,c) = c
|
||||
|
||||
--
|
||||
1.8.5.1
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
From 8e78a25ce0cc19e52d063f66bd4cd316462393d4 Mon Sep 17 00:00:00 2001
|
||||
From: dummy <dummy@example.com>
|
||||
Date: Thu, 6 Mar 2014 23:27:06 +0000
|
||||
Subject: [PATCH] disable th
|
||||
|
||||
---
|
||||
monad-logger.cabal | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/monad-logger.cabal b/monad-logger.cabal
|
||||
index b0aa271..cd56c0f 100644
|
||||
--- a/monad-logger.cabal
|
||||
+++ b/monad-logger.cabal
|
||||
@@ -14,8 +14,8 @@ cabal-version: >=1.8
|
||||
|
||||
flag template_haskell {
|
||||
Description: Enable Template Haskell support
|
||||
- Default: True
|
||||
- Manual: True
|
||||
+ Default: False
|
||||
+ Manual: False
|
||||
}
|
||||
|
||||
library
|
||||
--
|
||||
1.9.0
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
From c0f5dcfd6ba7a05bb84b6adc4664c8dde109e6ac Mon Sep 17 00:00:00 2001
|
||||
From: dummy <dummy@example.com>
|
||||
Date: Fri, 7 Mar 2014 04:30:22 +0000
|
||||
Subject: [PATCH] remove TH
|
||||
|
||||
---
|
||||
fast/Data/Reflection.hs | 8 +++++---
|
||||
1 file changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/fast/Data/Reflection.hs b/fast/Data/Reflection.hs
|
||||
index ca57d35..d3f8356 100644
|
||||
--- a/fast/Data/Reflection.hs
|
||||
+++ b/fast/Data/Reflection.hs
|
||||
@@ -59,7 +59,7 @@ module Data.Reflection
|
||||
, Given(..)
|
||||
, give
|
||||
-- * Template Haskell reflection
|
||||
- , int, nat
|
||||
+ --, int, nat
|
||||
-- * Useful compile time naturals
|
||||
, Z, D, SD, PD
|
||||
) where
|
||||
@@ -161,6 +161,7 @@ instance Reifies n Int => Reifies (PD n) Int where
|
||||
-- instead of @$(int 3)@. Sometimes the two will produce the same
|
||||
-- representation (if compiled without the @-DUSE_TYPE_LITS@ preprocessor
|
||||
-- directive).
|
||||
+{-
|
||||
int :: Int -> TypeQ
|
||||
int n = case quotRem n 2 of
|
||||
(0, 0) -> conT ''Z
|
||||
@@ -176,7 +177,7 @@ nat :: Int -> TypeQ
|
||||
nat n
|
||||
| n >= 0 = int n
|
||||
| otherwise = error "nat: negative"
|
||||
-
|
||||
+-}
|
||||
#if defined(__GLASGOW_HASKELL__) && __GLASGOW_HASKELL < 704
|
||||
instance Show (Q a)
|
||||
instance Eq (Q a)
|
||||
@@ -195,6 +196,7 @@ instance Fractional a => Fractional (Q a) where
|
||||
recip = fmap recip
|
||||
fromRational = return . fromRational
|
||||
|
||||
+{-
|
||||
-- | This permits the use of $(5) as a type splice.
|
||||
instance Num Type where
|
||||
#ifdef USE_TYPE_LITS
|
||||
@@ -254,7 +256,7 @@ instance Num Exp where
|
||||
abs = onProxyType1 abs
|
||||
signum = onProxyType1 signum
|
||||
fromInteger n = ConE 'Proxy `SigE` (ConT ''Proxy `AppT` fromInteger n)
|
||||
-
|
||||
+-}
|
||||
#ifdef USE_TYPE_LITS
|
||||
addProxy :: Proxy a -> Proxy b -> Proxy (a + b)
|
||||
addProxy _ _ = Proxy
|
||||
--
|
||||
1.9.0
|
||||
|
|
@ -1,366 +0,0 @@
|
|||
From 657fa7135bbcf3d5adb3cc0032e09887dd80a2a7 Mon Sep 17 00:00:00 2001
|
||||
From: dummy <dummy@example.com>
|
||||
Date: Thu, 16 Oct 2014 02:05:14 +0000
|
||||
Subject: [PATCH] hack TH
|
||||
|
||||
---
|
||||
Text/Cassius.hs | 23 --------
|
||||
Text/Css.hs | 151 --------------------------------------------------
|
||||
Text/CssCommon.hs | 4 --
|
||||
Text/Lucius.hs | 46 +--------------
|
||||
shakespeare-css.cabal | 2 +-
|
||||
5 files changed, 3 insertions(+), 223 deletions(-)
|
||||
|
||||
diff --git a/Text/Cassius.hs b/Text/Cassius.hs
|
||||
index 91fc90f..c515807 100644
|
||||
--- a/Text/Cassius.hs
|
||||
+++ b/Text/Cassius.hs
|
||||
@@ -13,10 +13,6 @@ module Text.Cassius
|
||||
, renderCss
|
||||
, renderCssUrl
|
||||
-- * Parsing
|
||||
- , cassius
|
||||
- , cassiusFile
|
||||
- , cassiusFileDebug
|
||||
- , cassiusFileReload
|
||||
-- * ToCss instances
|
||||
-- ** Color
|
||||
, Color (..)
|
||||
@@ -27,11 +23,8 @@ module Text.Cassius
|
||||
, AbsoluteUnit (..)
|
||||
, AbsoluteSize (..)
|
||||
, absoluteSize
|
||||
- , EmSize (..)
|
||||
- , ExSize (..)
|
||||
, PercentageSize (..)
|
||||
, percentageSize
|
||||
- , PixelSize (..)
|
||||
-- * Internal
|
||||
, cassiusUsedIdentifiers
|
||||
) where
|
||||
@@ -43,25 +36,9 @@ import Language.Haskell.TH.Quote (QuasiQuoter (..))
|
||||
import Language.Haskell.TH.Syntax
|
||||
import qualified Data.Text.Lazy as TL
|
||||
import Text.CssCommon
|
||||
-import Text.Lucius (lucius)
|
||||
import qualified Text.Lucius
|
||||
import Text.IndentToBrace (i2b)
|
||||
|
||||
-cassius :: QuasiQuoter
|
||||
-cassius = QuasiQuoter { quoteExp = quoteExp lucius . i2b }
|
||||
-
|
||||
-cassiusFile :: FilePath -> Q Exp
|
||||
-cassiusFile fp = do
|
||||
-#ifdef GHC_7_4
|
||||
- qAddDependentFile fp
|
||||
-#endif
|
||||
- contents <- fmap TL.unpack $ qRunIO $ readUtf8File fp
|
||||
- quoteExp cassius contents
|
||||
-
|
||||
-cassiusFileDebug, cassiusFileReload :: FilePath -> Q Exp
|
||||
-cassiusFileDebug = cssFileDebug True [|Text.Lucius.parseTopLevels|] Text.Lucius.parseTopLevels
|
||||
-cassiusFileReload = cassiusFileDebug
|
||||
-
|
||||
-- | Determine which identifiers are used by the given template, useful for
|
||||
-- creating systems like yesod devel.
|
||||
cassiusUsedIdentifiers :: String -> [(Deref, VarType)]
|
||||
diff --git a/Text/Css.hs b/Text/Css.hs
|
||||
index 75dc549..20c206c 100644
|
||||
--- a/Text/Css.hs
|
||||
+++ b/Text/Css.hs
|
||||
@@ -166,22 +166,6 @@ cssUsedIdentifiers toi2b parseBlocks s' =
|
||||
(scope, rest') = go rest
|
||||
go' (Attr k v) = k ++ v
|
||||
|
||||
-cssFileDebug :: Bool -- ^ perform the indent-to-brace conversion
|
||||
- -> Q Exp
|
||||
- -> Parser [TopLevel Unresolved]
|
||||
- -> FilePath
|
||||
- -> Q Exp
|
||||
-cssFileDebug toi2b parseBlocks' parseBlocks fp = do
|
||||
- s <- fmap TL.unpack $ qRunIO $ readUtf8File fp
|
||||
-#ifdef GHC_7_4
|
||||
- qAddDependentFile fp
|
||||
-#endif
|
||||
- let vs = cssUsedIdentifiers toi2b parseBlocks s
|
||||
- c <- mapM vtToExp vs
|
||||
- cr <- [|cssRuntime toi2b|]
|
||||
- parseBlocks'' <- parseBlocks'
|
||||
- return $ cr `AppE` parseBlocks'' `AppE` (LitE $ StringL fp) `AppE` ListE c
|
||||
-
|
||||
combineSelectors :: HasLeadingSpace
|
||||
-> [Contents]
|
||||
-> [Contents]
|
||||
@@ -287,18 +271,6 @@ cssRuntime toi2b parseBlocks fp cd render' = unsafePerformIO $ do
|
||||
|
||||
addScope scope = map (DerefIdent . Ident *** CDPlain . fromString) scope ++ cd
|
||||
|
||||
-vtToExp :: (Deref, VarType) -> Q Exp
|
||||
-vtToExp (d, vt) = do
|
||||
- d' <- lift d
|
||||
- c' <- c vt
|
||||
- return $ TupE [d', c' `AppE` derefToExp [] d]
|
||||
- where
|
||||
- c :: VarType -> Q Exp
|
||||
- c VTPlain = [|CDPlain . toCss|]
|
||||
- c VTUrl = [|CDUrl|]
|
||||
- c VTUrlParam = [|CDUrlParam|]
|
||||
- c VTMixin = [|CDMixin|]
|
||||
-
|
||||
getVars :: Monad m => [(String, String)] -> Content -> m [(Deref, VarType)]
|
||||
getVars _ ContentRaw{} = return []
|
||||
getVars scope (ContentVar d) =
|
||||
@@ -342,111 +314,8 @@ compressBlock (Block x y blocks mixins) =
|
||||
cc (ContentRaw a:ContentRaw b:c) = cc $ ContentRaw (a ++ b) : c
|
||||
cc (a:b) = a : cc b
|
||||
|
||||
-blockToMixin :: Name
|
||||
- -> Scope
|
||||
- -> Block Unresolved
|
||||
- -> Q Exp
|
||||
-blockToMixin r scope (Block _sel props subblocks mixins) =
|
||||
- [|Mixin
|
||||
- { mixinAttrs = concat
|
||||
- $ $(listE $ map go props)
|
||||
- : map mixinAttrs $mixinsE
|
||||
- -- FIXME too many complications to implement sublocks for now...
|
||||
- , mixinBlocks = [] -- foldr (.) id $(listE $ map subGo subblocks) []
|
||||
- }|]
|
||||
- {-
|
||||
- . foldr (.) id $(listE $ map subGo subblocks)
|
||||
- . (concatMap mixinBlocks $mixinsE ++)
|
||||
- |]
|
||||
- -}
|
||||
- where
|
||||
- mixinsE = return $ ListE $ map (derefToExp []) mixins
|
||||
- go (Attr x y) = conE 'Attr
|
||||
- `appE` (contentsToBuilder r scope x)
|
||||
- `appE` (contentsToBuilder r scope y)
|
||||
- subGo (Block sel' b c d) = blockToCss r scope $ Block sel' b c d
|
||||
-
|
||||
-blockToCss :: Name
|
||||
- -> Scope
|
||||
- -> Block Unresolved
|
||||
- -> Q Exp
|
||||
-blockToCss r scope (Block sel props subblocks mixins) =
|
||||
- [|((Block
|
||||
- { blockSelector = $(selectorToBuilder r scope sel)
|
||||
- , blockAttrs = concat
|
||||
- $ $(listE $ map go props)
|
||||
- : map mixinAttrs $mixinsE
|
||||
- , blockBlocks = ()
|
||||
- , blockMixins = ()
|
||||
- } :: Block Resolved):)
|
||||
- . foldr (.) id $(listE $ map subGo subblocks)
|
||||
- . (concatMap mixinBlocks $mixinsE ++)
|
||||
- |]
|
||||
- where
|
||||
- mixinsE = return $ ListE $ map (derefToExp []) mixins
|
||||
- go (Attr x y) = conE 'Attr
|
||||
- `appE` (contentsToBuilder r scope x)
|
||||
- `appE` (contentsToBuilder r scope y)
|
||||
- subGo (hls, Block sel' b c d) =
|
||||
- blockToCss r scope $ Block sel'' b c d
|
||||
- where
|
||||
- sel'' = combineSelectors hls sel sel'
|
||||
-
|
||||
-selectorToBuilder :: Name -> Scope -> [Contents] -> Q Exp
|
||||
-selectorToBuilder r scope sels =
|
||||
- contentsToBuilder r scope $ intercalate [ContentRaw ","] sels
|
||||
-
|
||||
-contentsToBuilder :: Name -> Scope -> [Content] -> Q Exp
|
||||
-contentsToBuilder r scope contents =
|
||||
- appE [|mconcat|] $ listE $ map (contentToBuilder r scope) contents
|
||||
-
|
||||
-contentToBuilder :: Name -> Scope -> Content -> Q Exp
|
||||
-contentToBuilder _ _ (ContentRaw x) =
|
||||
- [|fromText . pack|] `appE` litE (StringL x)
|
||||
-contentToBuilder _ scope (ContentVar d) =
|
||||
- case d of
|
||||
- DerefIdent (Ident s)
|
||||
- | Just val <- lookup s scope -> [|fromText . pack|] `appE` litE (StringL val)
|
||||
- _ -> [|toCss|] `appE` return (derefToExp [] d)
|
||||
-contentToBuilder r _ (ContentUrl u) =
|
||||
- [|fromText|] `appE`
|
||||
- (varE r `appE` return (derefToExp [] u) `appE` listE [])
|
||||
-contentToBuilder r _ (ContentUrlParam u) =
|
||||
- [|fromText|] `appE`
|
||||
- ([|uncurry|] `appE` varE r `appE` return (derefToExp [] u))
|
||||
-contentToBuilder _ _ ContentMixin{} = error "contentToBuilder on ContentMixin"
|
||||
-
|
||||
type Scope = [(String, String)]
|
||||
|
||||
-topLevelsToCassius :: [TopLevel Unresolved]
|
||||
- -> Q Exp
|
||||
-topLevelsToCassius a = do
|
||||
- r <- newName "_render"
|
||||
- lamE [varP r] $ appE [|CssNoWhitespace . foldr ($) []|] $ fmap ListE $ go r [] a
|
||||
- where
|
||||
- go _ _ [] = return []
|
||||
- go r scope (TopBlock b:rest) = do
|
||||
- e <- [|(++) $ map TopBlock ($(blockToCss r scope b) [])|]
|
||||
- es <- go r scope rest
|
||||
- return $ e : es
|
||||
- go r scope (TopAtBlock name s b:rest) = do
|
||||
- let s' = contentsToBuilder r scope s
|
||||
- e <- [|(:) $ TopAtBlock $(lift name) $(s') $(blocksToCassius r scope b)|]
|
||||
- es <- go r scope rest
|
||||
- return $ e : es
|
||||
- go r scope (TopAtDecl dec cs:rest) = do
|
||||
- e <- [|(:) $ TopAtDecl $(lift dec) $(contentsToBuilder r scope cs)|]
|
||||
- es <- go r scope rest
|
||||
- return $ e : es
|
||||
- go r scope (TopVar k v:rest) = go r ((k, v) : scope) rest
|
||||
-
|
||||
-blocksToCassius :: Name
|
||||
- -> Scope
|
||||
- -> [Block Unresolved]
|
||||
- -> Q Exp
|
||||
-blocksToCassius r scope a = do
|
||||
- appE [|foldr ($) []|] $ listE $ map (blockToCss r scope) a
|
||||
-
|
||||
renderCss :: Css -> TL.Text
|
||||
renderCss css =
|
||||
toLazyText $ mconcat $ map go tops
|
||||
@@ -515,23 +384,3 @@ renderBlock haveWhiteSpace indent (Block sel attrs () ())
|
||||
| haveWhiteSpace = fromString ";\n"
|
||||
| otherwise = singleton ';'
|
||||
|
||||
-instance Lift Mixin where
|
||||
- lift (Mixin a b) = [|Mixin a b|]
|
||||
-instance Lift (Attr Unresolved) where
|
||||
- lift (Attr k v) = [|Attr k v :: Attr Unresolved |]
|
||||
-instance Lift (Attr Resolved) where
|
||||
- lift (Attr k v) = [|Attr $(liftBuilder k) $(liftBuilder v) :: Attr Resolved |]
|
||||
-
|
||||
-liftBuilder :: Builder -> Q Exp
|
||||
-liftBuilder b = [|fromText $ pack $(lift $ TL.unpack $ toLazyText b)|]
|
||||
-
|
||||
-instance Lift Content where
|
||||
- lift (ContentRaw s) = [|ContentRaw s|]
|
||||
- lift (ContentVar d) = [|ContentVar d|]
|
||||
- lift (ContentUrl d) = [|ContentUrl d|]
|
||||
- lift (ContentUrlParam d) = [|ContentUrlParam d|]
|
||||
- lift (ContentMixin m) = [|ContentMixin m|]
|
||||
-instance Lift (Block Unresolved) where
|
||||
- lift (Block a b c d) = [|Block a b c d|]
|
||||
-instance Lift (Block Resolved) where
|
||||
- lift (Block a b () ()) = [|Block $(liftBuilder a) b () ()|]
|
||||
diff --git a/Text/CssCommon.hs b/Text/CssCommon.hs
|
||||
index 719e0a8..8c40e8c 100644
|
||||
--- a/Text/CssCommon.hs
|
||||
+++ b/Text/CssCommon.hs
|
||||
@@ -1,4 +1,3 @@
|
||||
-{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
|
||||
{-# LANGUAGE FlexibleInstances #-}
|
||||
{-# LANGUAGE CPP #-}
|
||||
@@ -156,6 +155,3 @@ showSize :: Rational -> String -> String
|
||||
showSize value' unit = printf "%f" value ++ unit
|
||||
where value = fromRational value' :: Double
|
||||
|
||||
-mkSizeType "EmSize" "em"
|
||||
-mkSizeType "ExSize" "ex"
|
||||
-mkSizeType "PixelSize" "px"
|
||||
diff --git a/Text/Lucius.hs b/Text/Lucius.hs
|
||||
index 346883d..f38492b 100644
|
||||
--- a/Text/Lucius.hs
|
||||
+++ b/Text/Lucius.hs
|
||||
@@ -8,13 +8,9 @@
|
||||
{-# OPTIONS_GHC -fno-warn-missing-fields #-}
|
||||
module Text.Lucius
|
||||
( -- * Parsing
|
||||
- lucius
|
||||
- , luciusFile
|
||||
- , luciusFileDebug
|
||||
- , luciusFileReload
|
||||
-- ** Mixins
|
||||
- , luciusMixin
|
||||
- , Mixin
|
||||
+ -- luciusMixin
|
||||
+ Mixin
|
||||
-- ** Runtime
|
||||
, luciusRT
|
||||
, luciusRT'
|
||||
@@ -40,11 +36,8 @@ module Text.Lucius
|
||||
, AbsoluteUnit (..)
|
||||
, AbsoluteSize (..)
|
||||
, absoluteSize
|
||||
- , EmSize (..)
|
||||
- , ExSize (..)
|
||||
, PercentageSize (..)
|
||||
, percentageSize
|
||||
- , PixelSize (..)
|
||||
-- * Internal
|
||||
, parseTopLevels
|
||||
, luciusUsedIdentifiers
|
||||
@@ -67,18 +60,6 @@ import Data.List (isSuffixOf)
|
||||
import Control.Arrow (second)
|
||||
import Text.Shakespeare (VarType)
|
||||
|
||||
--- |
|
||||
---
|
||||
--- >>> renderCss ([lucius|foo{bar:baz}|] undefined)
|
||||
--- "foo{bar:baz}"
|
||||
-lucius :: QuasiQuoter
|
||||
-lucius = QuasiQuoter { quoteExp = luciusFromString }
|
||||
-
|
||||
-luciusFromString :: String -> Q Exp
|
||||
-luciusFromString s =
|
||||
- topLevelsToCassius
|
||||
- $ either (error . show) id $ parse parseTopLevels s s
|
||||
-
|
||||
whiteSpace :: Parser ()
|
||||
whiteSpace = many whiteSpace1 >> return ()
|
||||
|
||||
@@ -218,17 +199,6 @@ parseComment = do
|
||||
_ <- manyTill anyChar $ try $ string "*/"
|
||||
return $ ContentRaw ""
|
||||
|
||||
-luciusFile :: FilePath -> Q Exp
|
||||
-luciusFile fp = do
|
||||
-#ifdef GHC_7_4
|
||||
- qAddDependentFile fp
|
||||
-#endif
|
||||
- contents <- fmap TL.unpack $ qRunIO $ readUtf8File fp
|
||||
- luciusFromString contents
|
||||
-
|
||||
-luciusFileDebug, luciusFileReload :: FilePath -> Q Exp
|
||||
-luciusFileDebug = cssFileDebug False [|parseTopLevels|] parseTopLevels
|
||||
-luciusFileReload = luciusFileDebug
|
||||
|
||||
parseTopLevels :: Parser [TopLevel Unresolved]
|
||||
parseTopLevels =
|
||||
@@ -377,15 +347,3 @@ luciusRTMinified tl scope = either Left (Right . renderCss . CssNoWhitespace) $
|
||||
-- creating systems like yesod devel.
|
||||
luciusUsedIdentifiers :: String -> [(Deref, VarType)]
|
||||
luciusUsedIdentifiers = cssUsedIdentifiers False parseTopLevels
|
||||
-
|
||||
-luciusMixin :: QuasiQuoter
|
||||
-luciusMixin = QuasiQuoter { quoteExp = luciusMixinFromString }
|
||||
-
|
||||
-luciusMixinFromString :: String -> Q Exp
|
||||
-luciusMixinFromString s' = do
|
||||
- r <- newName "_render"
|
||||
- case fmap compressBlock $ parse parseBlock s s of
|
||||
- Left e -> error $ show e
|
||||
- Right block -> blockToMixin r [] block
|
||||
- where
|
||||
- s = concat ["mixin{", s', "}"]
|
||||
diff --git a/shakespeare-css.cabal b/shakespeare-css.cabal
|
||||
index 2d3b25a..cc0553c 100644
|
||||
--- a/shakespeare-css.cabal
|
||||
+++ b/shakespeare-css.cabal
|
||||
@@ -35,8 +35,8 @@ library
|
||||
|
||||
exposed-modules: Text.Cassius
|
||||
Text.Lucius
|
||||
- other-modules: Text.MkSizeType
|
||||
Text.Css
|
||||
+ other-modules: Text.MkSizeType
|
||||
Text.IndentToBrace
|
||||
Text.CssCommon
|
||||
ghc-options: -Wall
|
||||
--
|
||||
2.1.1
|
||||
|
|
@ -1,316 +0,0 @@
|
|||
From 26f7328b0123d3ffa66873b91189ba3bdae3356c Mon Sep 17 00:00:00 2001
|
||||
From: dummy <dummy@example.com>
|
||||
Date: Thu, 16 Oct 2014 02:07:32 +0000
|
||||
Subject: [PATCH] hack TH
|
||||
|
||||
---
|
||||
Text/Coffee.hs | 56 ++++-----------------------------------------
|
||||
Text/Julius.hs | 67 +++++++++---------------------------------------------
|
||||
Text/Roy.hs | 51 ++++-------------------------------------
|
||||
Text/TypeScript.hs | 51 ++++-------------------------------------
|
||||
4 files changed, 24 insertions(+), 201 deletions(-)
|
||||
|
||||
diff --git a/Text/Coffee.hs b/Text/Coffee.hs
|
||||
index 488c81b..61db85b 100644
|
||||
--- a/Text/Coffee.hs
|
||||
+++ b/Text/Coffee.hs
|
||||
@@ -51,13 +51,13 @@ module Text.Coffee
|
||||
-- ** Template-Reading Functions
|
||||
-- | These QuasiQuoter and Template Haskell methods return values of
|
||||
-- type @'JavascriptUrl' url@. See the Yesod book for details.
|
||||
- coffee
|
||||
- , coffeeFile
|
||||
- , coffeeFileReload
|
||||
- , coffeeFileDebug
|
||||
+ -- coffee
|
||||
+ --, coffeeFile
|
||||
+ --, coffeeFileReload
|
||||
+ --, coffeeFileDebug
|
||||
|
||||
#ifdef TEST_EXPORT
|
||||
- , coffeeSettings
|
||||
+ --, coffeeSettings
|
||||
#endif
|
||||
) where
|
||||
|
||||
@@ -65,49 +65,3 @@ import Language.Haskell.TH.Quote (QuasiQuoter (..))
|
||||
import Language.Haskell.TH.Syntax
|
||||
import Text.Shakespeare
|
||||
import Text.Julius
|
||||
-
|
||||
-coffeeSettings :: Q ShakespeareSettings
|
||||
-coffeeSettings = do
|
||||
- jsettings <- javascriptSettings
|
||||
- return $ jsettings { varChar = '%'
|
||||
- , preConversion = Just PreConvert {
|
||||
- preConvert = ReadProcess "coffee" ["-spb"]
|
||||
- , preEscapeIgnoreBalanced = "'\"`" -- don't insert backtacks for variable already inside strings or backticks.
|
||||
- , preEscapeIgnoreLine = "#" -- ignore commented lines
|
||||
- , wrapInsertion = Just WrapInsertion {
|
||||
- wrapInsertionIndent = Just " "
|
||||
- , wrapInsertionStartBegin = "("
|
||||
- , wrapInsertionSeparator = ", "
|
||||
- , wrapInsertionStartClose = ") =>"
|
||||
- , wrapInsertionEnd = ""
|
||||
- , wrapInsertionAddParens = False
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
--- | Read inline, quasiquoted CoffeeScript.
|
||||
-coffee :: QuasiQuoter
|
||||
-coffee = QuasiQuoter { quoteExp = \s -> do
|
||||
- rs <- coffeeSettings
|
||||
- quoteExp (shakespeare rs) s
|
||||
- }
|
||||
-
|
||||
--- | Read in a CoffeeScript template file. This function reads the file once, at
|
||||
--- compile time.
|
||||
-coffeeFile :: FilePath -> Q Exp
|
||||
-coffeeFile fp = do
|
||||
- rs <- coffeeSettings
|
||||
- shakespeareFile rs fp
|
||||
-
|
||||
--- | Read in a CoffeeScript template file. This impure function uses
|
||||
--- unsafePerformIO to re-read the file on every call, allowing for rapid
|
||||
--- iteration.
|
||||
-coffeeFileReload :: FilePath -> Q Exp
|
||||
-coffeeFileReload fp = do
|
||||
- rs <- coffeeSettings
|
||||
- shakespeareFileReload rs fp
|
||||
-
|
||||
--- | Deprecated synonym for 'coffeeFileReload'
|
||||
-coffeeFileDebug :: FilePath -> Q Exp
|
||||
-coffeeFileDebug = coffeeFileReload
|
||||
-{-# DEPRECATED coffeeFileDebug "Please use coffeeFileReload instead." #-}
|
||||
diff --git a/Text/Julius.hs b/Text/Julius.hs
|
||||
index ec30690..5b5a075 100644
|
||||
--- a/Text/Julius.hs
|
||||
+++ b/Text/Julius.hs
|
||||
@@ -14,17 +14,17 @@ module Text.Julius
|
||||
-- ** Template-Reading Functions
|
||||
-- | These QuasiQuoter and Template Haskell methods return values of
|
||||
-- type @'JavascriptUrl' url@. See the Yesod book for details.
|
||||
- js
|
||||
- , julius
|
||||
- , juliusFile
|
||||
- , jsFile
|
||||
- , juliusFileDebug
|
||||
- , jsFileDebug
|
||||
- , juliusFileReload
|
||||
- , jsFileReload
|
||||
+ -- js
|
||||
+ -- julius
|
||||
+ -- juliusFile
|
||||
+ -- jsFile
|
||||
+ --, juliusFileDebug
|
||||
+ --, jsFileDebug
|
||||
+ --, juliusFileReload
|
||||
+ --, jsFileReload
|
||||
|
||||
-- * Datatypes
|
||||
- , JavascriptUrl
|
||||
+ JavascriptUrl
|
||||
, Javascript (..)
|
||||
, RawJavascript (..)
|
||||
|
||||
@@ -37,9 +37,9 @@ module Text.Julius
|
||||
, renderJavascriptUrl
|
||||
|
||||
-- ** internal, used by 'Text.Coffee'
|
||||
- , javascriptSettings
|
||||
+ --, javascriptSettings
|
||||
-- ** internal
|
||||
- , juliusUsedIdentifiers
|
||||
+ --, juliusUsedIdentifiers
|
||||
, asJavascriptUrl
|
||||
) where
|
||||
|
||||
@@ -102,48 +102,3 @@ instance RawJS TL.Text where rawJS = RawJavascript . fromLazyText
|
||||
instance RawJS Builder where rawJS = RawJavascript
|
||||
instance RawJS Bool where rawJS = RawJavascript . unJavascript . toJavascript
|
||||
|
||||
-javascriptSettings :: Q ShakespeareSettings
|
||||
-javascriptSettings = do
|
||||
- toJExp <- [|toJavascript|]
|
||||
- wrapExp <- [|Javascript|]
|
||||
- unWrapExp <- [|unJavascript|]
|
||||
- asJavascriptUrl' <- [|asJavascriptUrl|]
|
||||
- return $ defaultShakespeareSettings { toBuilder = toJExp
|
||||
- , wrap = wrapExp
|
||||
- , unwrap = unWrapExp
|
||||
- , modifyFinalValue = Just asJavascriptUrl'
|
||||
- }
|
||||
-
|
||||
-js, julius :: QuasiQuoter
|
||||
-js = QuasiQuoter { quoteExp = \s -> do
|
||||
- rs <- javascriptSettings
|
||||
- quoteExp (shakespeare rs) s
|
||||
- }
|
||||
-
|
||||
-julius = js
|
||||
-
|
||||
-jsFile, juliusFile :: FilePath -> Q Exp
|
||||
-jsFile fp = do
|
||||
- rs <- javascriptSettings
|
||||
- shakespeareFile rs fp
|
||||
-
|
||||
-juliusFile = jsFile
|
||||
-
|
||||
-
|
||||
-jsFileReload, juliusFileReload :: FilePath -> Q Exp
|
||||
-jsFileReload fp = do
|
||||
- rs <- javascriptSettings
|
||||
- shakespeareFileReload rs fp
|
||||
-
|
||||
-juliusFileReload = jsFileReload
|
||||
-
|
||||
-jsFileDebug, juliusFileDebug :: FilePath -> Q Exp
|
||||
-juliusFileDebug = jsFileReload
|
||||
-{-# DEPRECATED juliusFileDebug "Please use juliusFileReload instead." #-}
|
||||
-jsFileDebug = jsFileReload
|
||||
-{-# DEPRECATED jsFileDebug "Please use jsFileReload instead." #-}
|
||||
-
|
||||
--- | Determine which identifiers are used by the given template, useful for
|
||||
--- creating systems like yesod devel.
|
||||
-juliusUsedIdentifiers :: String -> [(Deref, VarType)]
|
||||
-juliusUsedIdentifiers = shakespeareUsedIdentifiers defaultShakespeareSettings
|
||||
diff --git a/Text/Roy.hs b/Text/Roy.hs
|
||||
index 6e5e246..9ab0dbc 100644
|
||||
--- a/Text/Roy.hs
|
||||
+++ b/Text/Roy.hs
|
||||
@@ -39,12 +39,12 @@ module Text.Roy
|
||||
-- ** Template-Reading Functions
|
||||
-- | These QuasiQuoter and Template Haskell methods return values of
|
||||
-- type @'JavascriptUrl' url@. See the Yesod book for details.
|
||||
- roy
|
||||
- , royFile
|
||||
- , royFileReload
|
||||
+ -- roy
|
||||
+ --, royFile
|
||||
+ --, royFileReload
|
||||
|
||||
#ifdef TEST_EXPORT
|
||||
- , roySettings
|
||||
+ --, roySettings
|
||||
#endif
|
||||
) where
|
||||
|
||||
@@ -53,46 +53,3 @@ import Language.Haskell.TH.Syntax
|
||||
import Text.Shakespeare
|
||||
import Text.Julius
|
||||
|
||||
--- | The Roy language compiles down to Javascript.
|
||||
--- We do this compilation once at compile time to avoid needing to do it during the request.
|
||||
--- We call this a preConversion because other shakespeare modules like Lucius use Haskell to compile during the request instead rather than a system call.
|
||||
-roySettings :: Q ShakespeareSettings
|
||||
-roySettings = do
|
||||
- jsettings <- javascriptSettings
|
||||
- return $ jsettings { varChar = '#'
|
||||
- , preConversion = Just PreConvert {
|
||||
- preConvert = ReadProcess "roy" ["--stdio", "--browser"]
|
||||
- , preEscapeIgnoreBalanced = "'\""
|
||||
- , preEscapeIgnoreLine = "//"
|
||||
- , wrapInsertion = Just WrapInsertion {
|
||||
- wrapInsertionIndent = Just " "
|
||||
- , wrapInsertionStartBegin = "(\\"
|
||||
- , wrapInsertionSeparator = " "
|
||||
- , wrapInsertionStartClose = " ->\n"
|
||||
- , wrapInsertionEnd = ")"
|
||||
- , wrapInsertionAddParens = True
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
--- | Read inline, quasiquoted Roy.
|
||||
-roy :: QuasiQuoter
|
||||
-roy = QuasiQuoter { quoteExp = \s -> do
|
||||
- rs <- roySettings
|
||||
- quoteExp (shakespeare rs) s
|
||||
- }
|
||||
-
|
||||
--- | Read in a Roy template file. This function reads the file once, at
|
||||
--- compile time.
|
||||
-royFile :: FilePath -> Q Exp
|
||||
-royFile fp = do
|
||||
- rs <- roySettings
|
||||
- shakespeareFile rs fp
|
||||
-
|
||||
--- | Read in a Roy template file. This impure function uses
|
||||
--- unsafePerformIO to re-read the file on every call, allowing for rapid
|
||||
--- iteration.
|
||||
-royFileReload :: FilePath -> Q Exp
|
||||
-royFileReload fp = do
|
||||
- rs <- roySettings
|
||||
- shakespeareFileReload rs fp
|
||||
diff --git a/Text/TypeScript.hs b/Text/TypeScript.hs
|
||||
index 70c8820..5be994a 100644
|
||||
--- a/Text/TypeScript.hs
|
||||
+++ b/Text/TypeScript.hs
|
||||
@@ -57,12 +57,12 @@ module Text.TypeScript
|
||||
-- ** Template-Reading Functions
|
||||
-- | These QuasiQuoter and Template Haskell methods return values of
|
||||
-- type @'JavascriptUrl' url@. See the Yesod book for details.
|
||||
- tsc
|
||||
- , typeScriptFile
|
||||
- , typeScriptFileReload
|
||||
+ -- tsc
|
||||
+ --, typeScriptFile
|
||||
+ --, typeScriptFileReload
|
||||
|
||||
#ifdef TEST_EXPORT
|
||||
- , typeScriptSettings
|
||||
+ --, typeScriptSettings
|
||||
#endif
|
||||
) where
|
||||
|
||||
@@ -71,46 +71,3 @@ import Language.Haskell.TH.Syntax
|
||||
import Text.Shakespeare
|
||||
import Text.Julius
|
||||
|
||||
--- | The TypeScript language compiles down to Javascript.
|
||||
--- We do this compilation once at compile time to avoid needing to do it during the request.
|
||||
--- We call this a preConversion because other shakespeare modules like Lucius use Haskell to compile during the request instead rather than a system call.
|
||||
-typeScriptSettings :: Q ShakespeareSettings
|
||||
-typeScriptSettings = do
|
||||
- jsettings <- javascriptSettings
|
||||
- return $ jsettings { varChar = '#'
|
||||
- , preConversion = Just PreConvert {
|
||||
- preConvert = ReadProcess "sh" ["-c", "TMP_IN=$(mktemp XXXXXXXXXX.ts); TMP_OUT=$(mktemp XXXXXXXXXX.js); cat /dev/stdin > ${TMP_IN} && tsc --out ${TMP_OUT} ${TMP_IN} && cat ${TMP_OUT}; rm ${TMP_IN} && rm ${TMP_OUT}"]
|
||||
- , preEscapeIgnoreBalanced = "'\""
|
||||
- , preEscapeIgnoreLine = "//"
|
||||
- , wrapInsertion = Just WrapInsertion {
|
||||
- wrapInsertionIndent = Nothing
|
||||
- , wrapInsertionStartBegin = ";(function("
|
||||
- , wrapInsertionSeparator = ", "
|
||||
- , wrapInsertionStartClose = "){"
|
||||
- , wrapInsertionEnd = "})"
|
||||
- , wrapInsertionAddParens = False
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
-
|
||||
--- | Read inline, quasiquoted TypeScript
|
||||
-tsc :: QuasiQuoter
|
||||
-tsc = QuasiQuoter { quoteExp = \s -> do
|
||||
- rs <- typeScriptSettings
|
||||
- quoteExp (shakespeare rs) s
|
||||
- }
|
||||
-
|
||||
--- | Read in a TypeScript template file. This function reads the file once, at
|
||||
--- compile time.
|
||||
-typeScriptFile :: FilePath -> Q Exp
|
||||
-typeScriptFile fp = do
|
||||
- rs <- typeScriptSettings
|
||||
- shakespeareFile rs fp
|
||||
-
|
||||
--- | Read in a Roy template file. This impure function uses
|
||||
--- unsafePerformIO to re-read the file on every call, allowing for rapid
|
||||
--- iteration.
|
||||
-typeScriptFileReload :: FilePath -> Q Exp
|
||||
-typeScriptFileReload fp = do
|
||||
- rs <- typeScriptSettings
|
||||
- shakespeareFileReload rs fp
|
||||
--
|
||||
2.1.1
|
||||
|
|
@ -1,108 +0,0 @@
|
|||
From b53713fbb4f3bb6bdd25b07afcaed4940b32dfa8 Mon Sep 17 00:00:00 2001
|
||||
From: Joey Hess <joey@kitenet.net>
|
||||
Date: Wed, 18 Dec 2013 03:32:44 +0000
|
||||
Subject: [PATCH] remove TH
|
||||
|
||||
---
|
||||
Text/Hamlet/XML.hs | 81 +-----------------------------------------------------
|
||||
1 file changed, 1 insertion(+), 80 deletions(-)
|
||||
|
||||
diff --git a/Text/Hamlet/XML.hs b/Text/Hamlet/XML.hs
|
||||
index f587410..4e830bd 100644
|
||||
--- a/Text/Hamlet/XML.hs
|
||||
+++ b/Text/Hamlet/XML.hs
|
||||
@@ -1,9 +1,7 @@
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# OPTIONS_GHC -fno-warn-missing-fields #-}
|
||||
module Text.Hamlet.XML
|
||||
- ( xml
|
||||
- , xmlFile
|
||||
- ) where
|
||||
+ () where
|
||||
|
||||
import Language.Haskell.TH.Syntax
|
||||
import Language.Haskell.TH.Quote
|
||||
@@ -19,80 +17,3 @@ import qualified Data.Foldable as F
|
||||
import Data.Maybe (fromMaybe)
|
||||
import qualified Data.Map as Map
|
||||
|
||||
-xml :: QuasiQuoter
|
||||
-xml = QuasiQuoter { quoteExp = strToExp }
|
||||
-
|
||||
-xmlFile :: FilePath -> Q Exp
|
||||
-xmlFile = strToExp . TL.unpack <=< qRunIO . readUtf8File
|
||||
-
|
||||
-strToExp :: String -> Q Exp
|
||||
-strToExp s =
|
||||
- case parseDoc s of
|
||||
- Error e -> error e
|
||||
- Ok x -> docsToExp [] x
|
||||
-
|
||||
-docsToExp :: Scope -> [Doc] -> Q Exp
|
||||
-docsToExp scope docs = [| concat $(fmap ListE $ mapM (docToExp scope) docs) |]
|
||||
-
|
||||
-docToExp :: Scope -> Doc -> Q Exp
|
||||
-docToExp scope (DocTag name attrs cs) =
|
||||
- [| [ X.NodeElement (X.Element ($(liftName name)) $(mkAttrs scope attrs) $(docsToExp scope cs))
|
||||
- ] |]
|
||||
-docToExp _ (DocContent (ContentRaw s)) = [| [ X.NodeContent (pack $(lift s)) ] |]
|
||||
-docToExp scope (DocContent (ContentVar d)) = [| [ X.NodeContent $(return $ derefToExp scope d) ] |]
|
||||
-docToExp scope (DocContent (ContentEmbed d)) = return $ derefToExp scope d
|
||||
-docToExp scope (DocForall deref ident@(Ident ident') inside) = do
|
||||
- let list' = derefToExp scope deref
|
||||
- name <- newName ident'
|
||||
- let scope' = (ident, VarE name) : scope
|
||||
- inside' <- docsToExp scope' inside
|
||||
- let lam = LamE [VarP name] inside'
|
||||
- [| F.concatMap $(return lam) $(return list') |]
|
||||
-docToExp scope (DocWith [] inside) = docsToExp scope inside
|
||||
-docToExp scope (DocWith ((deref, ident@(Ident name)):dis) inside) = do
|
||||
- let deref' = derefToExp scope deref
|
||||
- name' <- newName name
|
||||
- let scope' = (ident, VarE name') : scope
|
||||
- inside' <- docToExp scope' (DocWith dis inside)
|
||||
- let lam = LamE [VarP name'] inside'
|
||||
- return $ lam `AppE` deref'
|
||||
-docToExp scope (DocMaybe deref ident@(Ident name) just nothing) = do
|
||||
- let deref' = derefToExp scope deref
|
||||
- name' <- newName name
|
||||
- let scope' = (ident, VarE name') : scope
|
||||
- inside' <- docsToExp scope' just
|
||||
- let inside'' = LamE [VarP name'] inside'
|
||||
- nothing' <-
|
||||
- case nothing of
|
||||
- Nothing -> [| [] |]
|
||||
- Just n -> docsToExp scope n
|
||||
- [| maybe $(return nothing') $(return inside'') $(return deref') |]
|
||||
-docToExp scope (DocCond conds final) = do
|
||||
- unit <- [| () |]
|
||||
- body <- fmap GuardedB $ mapM go $ conds ++ [(DerefIdent $ Ident "otherwise", fromMaybe [] final)]
|
||||
- return $ CaseE unit [Match (TupP []) body []]
|
||||
- where
|
||||
- go (deref, inside) = do
|
||||
- inside' <- docsToExp scope inside
|
||||
- return (NormalG $ derefToExp scope deref, inside')
|
||||
-
|
||||
-mkAttrs :: Scope -> [(Maybe Deref, String, [Content])] -> Q Exp
|
||||
-mkAttrs _ [] = [| Map.empty |]
|
||||
-mkAttrs scope ((mderef, name, value):rest) = do
|
||||
- rest' <- mkAttrs scope rest
|
||||
- this <- [| Map.insert $(liftName name) (T.concat $(fmap ListE $ mapM go value)) |]
|
||||
- let with = [| $(return this) $(return rest') |]
|
||||
- case mderef of
|
||||
- Nothing -> with
|
||||
- Just deref -> [| if $(return $ derefToExp scope deref) then $(with) else $(return rest') |]
|
||||
- where
|
||||
- go (ContentRaw s) = [| pack $(lift s) |]
|
||||
- go (ContentVar d) = return $ derefToExp scope d
|
||||
- go ContentEmbed{} = error "Cannot use embed interpolation in attribute value"
|
||||
-
|
||||
-liftName :: String -> Q Exp
|
||||
-liftName s = do
|
||||
- X.Name local mns _ <- return $ fromString s
|
||||
- case mns of
|
||||
- Nothing -> [| X.Name (pack $(lift $ unpack local)) Nothing Nothing |]
|
||||
- Just ns -> [| X.Name (pack $(lift $ unpack local)) (Just $ pack $(lift $ unpack ns)) Nothing |]
|
||||
--
|
||||
1.8.5.1
|
||||
|
|
@ -1,170 +0,0 @@
|
|||
From 8ba08c0efc035486a65f2fd33916a5da7e5210e7 Mon Sep 17 00:00:00 2001
|
||||
From: dummy <dummy@example.com>
|
||||
Date: Thu, 26 Dec 2013 19:32:55 -0400
|
||||
Subject: [PATCH] remove TH
|
||||
|
||||
---
|
||||
Yesod/Routes/Parse.hs | 40 +++++-----------------------------------
|
||||
Yesod/Routes/TH.hs | 16 ++++++++--------
|
||||
Yesod/Routes/TH/Types.hs | 16 ----------------
|
||||
yesod-routes.cabal | 4 ----
|
||||
4 files changed, 13 insertions(+), 63 deletions(-)
|
||||
|
||||
diff --git a/Yesod/Routes/Parse.hs b/Yesod/Routes/Parse.hs
|
||||
index 232982d..7df7750 100644
|
||||
--- a/Yesod/Routes/Parse.hs
|
||||
+++ b/Yesod/Routes/Parse.hs
|
||||
@@ -2,11 +2,11 @@
|
||||
{-# LANGUAGE DeriveDataTypeable #-}
|
||||
{-# OPTIONS_GHC -fno-warn-missing-fields #-} -- QuasiQuoter
|
||||
module Yesod.Routes.Parse
|
||||
- ( parseRoutes
|
||||
- , parseRoutesFile
|
||||
- , parseRoutesNoCheck
|
||||
- , parseRoutesFileNoCheck
|
||||
- , parseType
|
||||
+ --( parseRoutes
|
||||
+ --, parseRoutesFile
|
||||
+ --, parseRoutesNoCheck
|
||||
+ --, parseRoutesFileNoCheck
|
||||
+ ( parseType
|
||||
, parseTypeTree
|
||||
, TypeTree (..)
|
||||
) where
|
||||
@@ -19,42 +19,12 @@ import Yesod.Routes.TH
|
||||
import Yesod.Routes.Overlap (findOverlapNames)
|
||||
import Data.List (foldl')
|
||||
|
||||
--- | A quasi-quoter to parse a string into a list of 'Resource's. Checks for
|
||||
--- overlapping routes, failing if present; use 'parseRoutesNoCheck' to skip the
|
||||
--- checking. See documentation site for details on syntax.
|
||||
-parseRoutes :: QuasiQuoter
|
||||
-parseRoutes = QuasiQuoter { quoteExp = x }
|
||||
- where
|
||||
- x s = do
|
||||
- let res = resourcesFromString s
|
||||
- case findOverlapNames res of
|
||||
- [] -> lift res
|
||||
- z -> error $ unlines $ "Overlapping routes: " : map show z
|
||||
-
|
||||
-parseRoutesFile :: FilePath -> Q Exp
|
||||
-parseRoutesFile = parseRoutesFileWith parseRoutes
|
||||
-
|
||||
-parseRoutesFileNoCheck :: FilePath -> Q Exp
|
||||
-parseRoutesFileNoCheck = parseRoutesFileWith parseRoutesNoCheck
|
||||
-
|
||||
-parseRoutesFileWith :: QuasiQuoter -> FilePath -> Q Exp
|
||||
-parseRoutesFileWith qq fp = do
|
||||
- qAddDependentFile fp
|
||||
- s <- qRunIO $ readUtf8File fp
|
||||
- quoteExp qq s
|
||||
-
|
||||
readUtf8File :: FilePath -> IO String
|
||||
readUtf8File fp = do
|
||||
h <- SIO.openFile fp SIO.ReadMode
|
||||
SIO.hSetEncoding h SIO.utf8_bom
|
||||
SIO.hGetContents h
|
||||
|
||||
--- | Same as 'parseRoutes', but performs no overlap checking.
|
||||
-parseRoutesNoCheck :: QuasiQuoter
|
||||
-parseRoutesNoCheck = QuasiQuoter
|
||||
- { quoteExp = lift . resourcesFromString
|
||||
- }
|
||||
-
|
||||
-- | Convert a multi-line string to a set of resources. See documentation for
|
||||
-- the format of this string. This is a partial function which calls 'error' on
|
||||
-- invalid input.
|
||||
diff --git a/Yesod/Routes/TH.hs b/Yesod/Routes/TH.hs
|
||||
index 7b2e50b..b05fc57 100644
|
||||
--- a/Yesod/Routes/TH.hs
|
||||
+++ b/Yesod/Routes/TH.hs
|
||||
@@ -2,15 +2,15 @@
|
||||
module Yesod.Routes.TH
|
||||
( module Yesod.Routes.TH.Types
|
||||
-- * Functions
|
||||
- , module Yesod.Routes.TH.RenderRoute
|
||||
- , module Yesod.Routes.TH.ParseRoute
|
||||
- , module Yesod.Routes.TH.RouteAttrs
|
||||
+ -- , module Yesod.Routes.TH.RenderRoute
|
||||
+ -- , module Yesod.Routes.TH.ParseRoute
|
||||
+ -- , module Yesod.Routes.TH.RouteAttrs
|
||||
-- ** Dispatch
|
||||
- , module Yesod.Routes.TH.Dispatch
|
||||
+ -- , module Yesod.Routes.TH.Dispatch
|
||||
) where
|
||||
|
||||
import Yesod.Routes.TH.Types
|
||||
-import Yesod.Routes.TH.RenderRoute
|
||||
-import Yesod.Routes.TH.ParseRoute
|
||||
-import Yesod.Routes.TH.RouteAttrs
|
||||
-import Yesod.Routes.TH.Dispatch
|
||||
+--import Yesod.Routes.TH.RenderRoute
|
||||
+--import Yesod.Routes.TH.ParseRoute
|
||||
+--import Yesod.Routes.TH.RouteAttrs
|
||||
+--import Yesod.Routes.TH.Dispatch
|
||||
diff --git a/Yesod/Routes/TH/Types.hs b/Yesod/Routes/TH/Types.hs
|
||||
index d0a0405..3232e99 100644
|
||||
--- a/Yesod/Routes/TH/Types.hs
|
||||
+++ b/Yesod/Routes/TH/Types.hs
|
||||
@@ -31,10 +31,6 @@ instance Functor ResourceTree where
|
||||
fmap f (ResourceLeaf r) = ResourceLeaf (fmap f r)
|
||||
fmap f (ResourceParent a b c) = ResourceParent a (map (second $ fmap f) b) $ map (fmap f) c
|
||||
|
||||
-instance Lift t => Lift (ResourceTree t) where
|
||||
- lift (ResourceLeaf r) = [|ResourceLeaf $(lift r)|]
|
||||
- lift (ResourceParent a b c) = [|ResourceParent $(lift a) $(lift b) $(lift c)|]
|
||||
-
|
||||
data Resource typ = Resource
|
||||
{ resourceName :: String
|
||||
, resourcePieces :: [(CheckOverlap, Piece typ)]
|
||||
@@ -48,9 +44,6 @@ type CheckOverlap = Bool
|
||||
instance Functor Resource where
|
||||
fmap f (Resource a b c d) = Resource a (map (second $ fmap f) b) (fmap f c) d
|
||||
|
||||
-instance Lift t => Lift (Resource t) where
|
||||
- lift (Resource a b c d) = [|Resource a b c d|]
|
||||
-
|
||||
data Piece typ = Static String | Dynamic typ
|
||||
deriving Show
|
||||
|
||||
@@ -58,10 +51,6 @@ instance Functor Piece where
|
||||
fmap _ (Static s) = (Static s)
|
||||
fmap f (Dynamic t) = Dynamic (f t)
|
||||
|
||||
-instance Lift t => Lift (Piece t) where
|
||||
- lift (Static s) = [|Static $(lift s)|]
|
||||
- lift (Dynamic t) = [|Dynamic $(lift t)|]
|
||||
-
|
||||
data Dispatch typ =
|
||||
Methods
|
||||
{ methodsMulti :: Maybe typ -- ^ type of the multi piece at the end
|
||||
@@ -77,11 +66,6 @@ instance Functor Dispatch where
|
||||
fmap f (Methods a b) = Methods (fmap f a) b
|
||||
fmap f (Subsite a b) = Subsite (f a) b
|
||||
|
||||
-instance Lift t => Lift (Dispatch t) where
|
||||
- lift (Methods Nothing b) = [|Methods Nothing $(lift b)|]
|
||||
- lift (Methods (Just t) b) = [|Methods (Just $(lift t)) $(lift b)|]
|
||||
- lift (Subsite t b) = [|Subsite $(lift t) $(lift b)|]
|
||||
-
|
||||
resourceMulti :: Resource typ -> Maybe typ
|
||||
resourceMulti Resource { resourceDispatch = Methods (Just t) _ } = Just t
|
||||
resourceMulti _ = Nothing
|
||||
diff --git a/yesod-routes.cabal b/yesod-routes.cabal
|
||||
index 61980d1..33d2380 100644
|
||||
--- a/yesod-routes.cabal
|
||||
+++ b/yesod-routes.cabal
|
||||
@@ -27,10 +27,6 @@ library
|
||||
Yesod.Routes.Class
|
||||
Yesod.Routes.Parse
|
||||
Yesod.Routes.Overlap
|
||||
- other-modules: Yesod.Routes.TH.Dispatch
|
||||
- Yesod.Routes.TH.RenderRoute
|
||||
- Yesod.Routes.TH.ParseRoute
|
||||
- Yesod.Routes.TH.RouteAttrs
|
||||
Yesod.Routes.TH.Types
|
||||
ghc-options: -Wall
|
||||
|
||||
--
|
||||
1.7.10.4
|
||||
|
Loading…
Reference in a new issue