Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Blaze/ByteString/Builder.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{-# LANGUAGE CPP, BangPatterns #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif

------------------------------------------------------------------------------
-- |
Expand Down
17 changes: 6 additions & 11 deletions Blaze/ByteString/Builder/ByteString.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif

------------------------------------------------------------------------------
-- |
-- Module: Blaze.ByteString.Builder.ByteString
Expand Down Expand Up @@ -33,24 +38,14 @@ module Blaze.ByteString.Builder.ByteString

) where

import Blaze.ByteString.Builder.Internal.Write (writeByteString)

import Blaze.ByteString.Builder.Internal.Write ( Write, exactWrite )
import Foreign
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Builder.Extra as B
import qualified Data.ByteString as S
import qualified Data.ByteString.Internal as S
import qualified Data.ByteString.Lazy as L


-- | Write a strict 'S.ByteString' to a buffer.
writeByteString :: S.ByteString -> Write
writeByteString bs = exactWrite l io
where
(fptr, o, l) = S.toForeignPtr bs
io pf = withForeignPtr fptr $ \p -> copyBytes pf (p `plusPtr` o) l
{-# INLINE writeByteString #-}

-- | Create a 'B.Builder' denoting the same sequence of bytes as a strict
-- 'S.ByteString'.
-- The 'B.Builder' inserts large 'S.ByteString's directly, but copies small ones
Expand Down
5 changes: 5 additions & 0 deletions Blaze/ByteString/Builder/Char/Utf8.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Safe #-}
#endif

------------------------------------------------------------------------------
-- |
-- Module: Blaze.ByteString.Builder.Char.Utf8
Expand Down
5 changes: 5 additions & 0 deletions Blaze/ByteString/Builder/Char8.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Safe #-}
#endif

------------------------------------------------------------------------------
-- |
-- Module: Blaze.ByteString.Builder.Char8
Expand Down
5 changes: 5 additions & 0 deletions Blaze/ByteString/Builder/Compat/Write.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif

------------------------------------------------------------------------------
-- |
-- Module: Blaze.ByteString.Builder.Compat.Write
Expand Down
3 changes: 3 additions & 0 deletions Blaze/ByteString/Builder/HTTP.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{-# LANGUAGE BangPatterns, CPP, MagicHash, OverloadedStrings #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Trustworthy #-}
#endif
------------------------------------------------------------------------------
-- |
-- Module: Blaze.ByteString.Builder.HTTP
Expand Down
3 changes: 3 additions & 0 deletions Blaze/ByteString/Builder/Html/Utf8.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#if __GLASGOW_HASKELL__ >= 704
{-# OPTIONS_GHC -fsimpl-tick-factor=40000 #-}
#endif
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Safe #-}
#endif

------------------------------------------------------------------------------
-- |
Expand Down
5 changes: 5 additions & 0 deletions Blaze/ByteString/Builder/Int.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Safe #-}
#endif

------------------------------------------------------------------------------
-- |
-- Module: Blaze.ByteString.Builder.Int
Expand Down
13 changes: 13 additions & 0 deletions Blaze/ByteString/Builder/Internal/Write.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{-# LANGUAGE CPP, BangPatterns #-}
#if __GLASGOW_HASKELL__ >= 704
{-# LANGUAGE Unsafe #-}
#endif

-- |
-- Module : Blaze.ByteString.Builder.Internal.Poke
Expand Down Expand Up @@ -45,13 +48,15 @@ module Blaze.ByteString.Builder.Internal.Write (
, fromStorable
, fromStorables

, writeByteString
) where

import Foreign

import Control.Monad

import Data.ByteString.Builder.Internal
import Data.ByteString.Internal as S

#if !MIN_VERSION_base(4,8,0)
import Data.Monoid
Expand Down Expand Up @@ -286,3 +291,11 @@ fromStorable = fromWriteSingleton writeStorable
-- provided externally.
fromStorables :: Storable a => [a] -> Builder
fromStorables = fromWriteList writeStorable

-- | Write a strict 'S.ByteString' to a buffer.
writeByteString :: S.ByteString -> Write
writeByteString bs = exactWrite l io
where
(fptr, o, l) = S.toForeignPtr bs
io pf = withForeignPtr fptr $ \p -> copyBytes pf (p `plusPtr` o) l
{-# INLINE writeByteString #-}
5 changes: 5 additions & 0 deletions Blaze/ByteString/Builder/Word.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 702
{-# LANGUAGE Safe #-}
#endif

------------------------------------------------------------------------------
-- |
-- Module: Blaze.ByteString.Builder.Word
Expand Down
3 changes: 3 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
* 0.4.1.0
- Add Safe Haskell pragmas

* 0.4.0.2
- Fixed warnings on GHC 7.10, courtesy of Mikhail Glushenkov.

Expand Down
2 changes: 1 addition & 1 deletion blaze-builder.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: blaze-builder
Version: 0.4.0.2
Version: 0.4.1.0
Synopsis: Efficient buffered output.

Description:
Expand Down