Skip to content

Commit

Permalink
Version 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
thsutton committed Nov 27, 2010
1 parent 268972b commit a361c2f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Original file line Diff line number Diff line change
@@ -1 +1,3 @@
/dist /dist
*.hi
*.o
19 changes: 10 additions & 9 deletions Blaze/ByteString/Builder/Enumerator.hs
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
-- Stability : Experimental -- Stability : Experimental
-- Portability : Unknown -- Portability : Unknown
-- --
-- Wrap -- Simplify the process of using @blaze-builder@ with @enumerator@ by
-- converting functions that construct 'Builder's into 'Iteratee's.
------------------------------------------------------------------------------ ------------------------------------------------------------------------------


module Blaze.ByteString.Builder.Enumerator where module Blaze.ByteString.Builder.Enumerator where
Expand All @@ -16,12 +17,12 @@ import qualified Data.ByteString as B
import Data.Enumerator import Data.Enumerator


-- | Convert a function that returns a @blaze-builder@ 'Builder' into an -- | Convert a function that returns a @blaze-builder@ 'Builder' into an
-- 'Iteratee'. Each incoming value will be converted into a lazy 'ByteString'. -- 'Iteratee'. Each incoming value will be converted into a 'ByteString'.
iterBuilder :: Monad m => (a -> Builder) -> Iteratee a m B.ByteString iterBuilder :: Monad m => (a -> Builder) -> Iteratee a m B.ByteString
iterBuilder build = continue (step build) iterBuilder builder = continue (step builder)

where
step :: Monad m => (a -> Builder) -> Stream a -> Iteratee a m B.ByteString step :: Monad m => (a -> Builder) -> Stream a -> Iteratee a m B.ByteString
step build input = case input of step b input = case input of
EOF -> yield (B.empty) EOF EOF -> yield (B.empty) EOF
Chunks [] -> continue (step build) Chunks [] -> continue (step b)
Chunks (v:vs) -> yield (toByteString $ build v) (Chunks vs) Chunks (v:vs) -> yield (toByteString $ b v) (Chunks vs)
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,25 @@
The following license covers this documentation, and the source code, except
where otherwise indicated.

Copyright 2010, Thomas Sutton. 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.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "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 HOLDERS 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.
2 changes: 2 additions & 0 deletions Setup.hs
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,2 @@
import Distribution.Simple
main = defaultMain
26 changes: 14 additions & 12 deletions blaze-builder-enumerator.cabal
Original file line number Original file line Diff line number Diff line change
@@ -1,32 +1,34 @@
Name : blaze-builder-enumerator Name : blaze-builder-enumerator
Version : 0.1 Version : 0.1
Synopsis : A combinator for using blaze-builder with enumerator. Synopsis : A combinator for using blaze-builder with enumerator.
Description : A combinator for using blaze-builder with enumerator. Description :

This package simplifies the process of using blaze-builder with the
enumerator package by converting a function that constructs a Builder into
an Iteratee.

Author : Thomas Sutton <me@thomas-sutton.id.au> Author : Thomas Sutton <me@thomas-sutton.id.au>
Maintainer : me@thomas-sutton.id.au Maintainer : me@thomas-sutton.id.au
Copyright : Copyright (c) Thomas Sutton 2010 Copyright : Copyright (c) Thomas Sutton 2010
License : BSD3 License : BSD3
License-file : LICENSE
Build-type : Simple Build-type : Simple
Cabal-version : >=1.6 Cabal-version : >=1.6
Category : Data, Text, Enumerator Category : Data, Text, Enumerator
Stability : Experimental Stability : Experimental
Bug-reports : mailto:me@thomas-sutton.id.au Bug-reports : mailto:me@thomas-sutton.id.au
Homepage : http://github.com/thsutton/blaze-builder-enumerator Homepage : http://github.com/thsutton/blaze-builder-enumerator
Tested-with : GHC==6.12.1

source-repository head
type: git
location: http://github.com/thsutton/blaze-builder-enumerator


Source-repository head
Type: git
Location: http://github.com/thsutton/blaze-builder-enumerator


Library Library
ghc-options: -Wall -fno-warn-unused-do-bind GHC-options: -Wall -fno-warn-unused-do-bind

Build-depends:
build-depends:
base >= 4 && < 5 base >= 4 && < 5
, blaze-builder >= 0.2 && < 0.3 , blaze-builder >= 0.2 && < 0.3
, bytestring >= 0.9 && < 0.10 , bytestring >= 0.9 && < 0.10
, enumerator >= 0.4 && < 0.5 , enumerator >= 0.4 && < 0.5

Exposed-modules:
exposed-modules: Blaze.ByteString.Builder.Enumerator
Blaze.ByteString.Builder.Enumerator

0 comments on commit a361c2f

Please sign in to comment.