Permalink
Browse files

Prevent code size explosion for Lucius (yesodweb/yesod#298)

  • Loading branch information...
1 parent e80acd2 commit 0f82d588542c69772543ae2f671907c4285e0682 @snoyberg snoyberg committed Mar 28, 2012
Showing with 14 additions and 5 deletions.
  1. +1 −1 shakespeare-css/Text/Cassius.hs
  2. +12 −2 shakespeare-css/Text/Css.hs
  3. +1 −2 shakespeare-css/Text/Lucius.hs
@@ -42,7 +42,7 @@ import Text.Printf (printf)
import Language.Haskell.TH.Quote (QuasiQuoter (..))
import Language.Haskell.TH.Syntax
import Language.Haskell.TH
-import Data.Text.Lazy.Builder (fromText, fromLazyText)
+import Data.Text.Lazy.Builder (fromLazyText)
import Data.Maybe (catMaybes)
import Data.Word (Word8)
import Data.Bits
@@ -6,10 +6,12 @@
module Text.Css where
import Data.List (intersperse, intercalate)
-import Data.Text.Lazy.Builder (Builder, fromText, singleton, toLazyText, fromLazyText, fromString)
+import Data.Text.Lazy.Builder (Builder, singleton, toLazyText, fromLazyText, fromString)
import qualified Data.Text.Lazy as TL
+import qualified Data.Text.Lazy.Builder as TLB
import Data.Monoid (mconcat, mappend, mempty)
-import Data.Text (Text, pack)
+import Data.Text (Text)
+import qualified Data.Text as T
import Language.Haskell.TH.Syntax
import System.IO.Unsafe (unsafePerformIO)
import Text.ParserCombinators.Parsec (Parser, parse)
@@ -18,6 +20,14 @@ import Language.Haskell.TH
import Control.Applicative ((<$>), (<*>))
import Control.Arrow ((***))
+pack :: String -> Text
+pack = T.pack
+{-# NOINLINE pack #-}
+
+fromText :: Text -> Builder
+fromText = TLB.fromText
+{-# NOINLINE fromText #-}
+
class ToCss a where
toCss :: a -> Builder
@@ -21,7 +21,7 @@ import Text.Cassius hiding (cassius, cassiusFile, cassiusFileDebug, cassiusFileR
import Text.Shakespeare.Base
import Language.Haskell.TH.Quote (QuasiQuoter (..))
import Language.Haskell.TH.Syntax
-import Data.Text (Text, pack, unpack)
+import Data.Text (Text, unpack)
import qualified Data.Text.Lazy as TL
import Text.ParserCombinators.Parsec hiding (Line)
import Text.Css
@@ -30,7 +30,6 @@ import Numeric (readHex)
import Control.Applicative ((<$>))
import Control.Monad (when)
import Data.Either (partitionEithers)
-import Data.Text.Lazy.Builder (fromText)
import Data.Monoid (mconcat)
-- |

0 comments on commit 0f82d58

Please sign in to comment.