refreshed haskell patches

This commit is contained in:
Joey Hess 2014-06-11 03:35:19 +01:00
parent 5ec8bcfaa7
commit 2b8dbfe7ab
8 changed files with 102 additions and 103 deletions

View file

@ -1,17 +1,17 @@
From cd49a96991dc3dd8867038fa9d426a8ccdb25f8d Mon Sep 17 00:00:00 2001
From: Joey Hess <joey@kitenet.net>
Date: Tue, 17 Dec 2013 18:40:48 +0000
From 2b41af230ea5675592e87a2362d9c17bcd8df1db Mon Sep 17 00:00:00 2001
From: dummy <dummy@example.com>
Date: Tue, 10 Jun 2014 19:00:44 +0000
Subject: [PATCH] remove TH
---
Data/FileEmbed.hs | 87 ++++---------------------------------------------------
1 file changed, 5 insertions(+), 82 deletions(-)
Data/FileEmbed.hs | 100 +++---------------------------------------------------
1 file changed, 5 insertions(+), 95 deletions(-)
diff --git a/Data/FileEmbed.hs b/Data/FileEmbed.hs
index 5617493..ad92cdc 100644
index aae9d5a..efdbb7b 100644
--- a/Data/FileEmbed.hs
+++ b/Data/FileEmbed.hs
@@ -17,13 +17,13 @@
@@ -17,19 +17,18 @@
-- > {-# LANGUAGE TemplateHaskell #-}
module Data.FileEmbed
( -- * Embed at compile time
@ -30,7 +30,13 @@ index 5617493..ad92cdc 100644
#endif
, inject
, injectFile
@@ -56,72 +56,11 @@ import Data.ByteString.Unsafe (unsafePackAddressLen)
-- * Internal
, stringToBs
- , bsToExp
) where
import Language.Haskell.TH.Syntax
@@ -57,85 +56,12 @@ import Data.ByteString.Unsafe (unsafePackAddressLen)
import System.IO.Unsafe (unsafePerformIO)
import System.FilePath ((</>))
@ -81,7 +87,7 @@ index 5617493..ad92cdc 100644
- e <- ListE <$> ((runIO $ fileList fp) >>= mapM (pairToExp fp))
- return $ SigE e typ
-
--- | Get a directory tree in the IO monad.
-- | Get a directory tree in the IO monad.
--
-- This is the workhorse of 'embedDir'
getDir :: FilePath -> IO [(FilePath, B.ByteString)]
@ -96,14 +102,27 @@ index 5617493..ad92cdc 100644
- return $! TupE [LitE $ StringL path, exp']
-
-bsToExp :: B.ByteString -> Q Exp
-#if MIN_VERSION_template_haskell(2, 5, 0)
-bsToExp bs =
- return $ VarE 'unsafePerformIO
- `AppE` (VarE 'unsafePackAddressLen
- `AppE` LitE (IntegerL $ fromIntegral $ B8.length bs)
-#if MIN_VERSION_template_haskell(2, 8, 0)
- `AppE` LitE (StringPrimL $ B.unpack bs))
-#else
- `AppE` LitE (StringPrimL $ B8.unpack bs))
-#endif
-#else
-bsToExp bs = do
- helper <- [| stringToBs |]
- let chars = B8.unpack bs
- return $! AppE helper $! LitE $! StringL chars
-#endif
-
stringToBs :: String -> B.ByteString
stringToBs = B8.pack
@@ -164,22 +103,6 @@ padSize i =
@@ -177,22 +103,6 @@ padSize i =
let s = show i
in replicate (sizeLen - length s) '0' ++ s
@ -127,5 +146,5 @@ index 5617493..ad92cdc 100644
inject :: B.ByteString -- ^ bs to inject
-> B.ByteString -- ^ original BS containing dummy
--
1.8.5.1
2.0.0