Permalink
Browse files

Version 0.1

  • Loading branch information...
thsutton committed Nov 27, 2010
1 parent 268972b commit a361c2f4433bbb63e9493ba4232f04f488c46c6f
Showing with 53 additions and 21 deletions.
  1. +2 −0 .gitignore
  2. +10 −9 Blaze/ByteString/Builder/Enumerator.hs
  3. +25 −0 LICENSE
  4. +2 −0 Setup.hs
  5. +14 −12 blaze-builder-enumerator.cabal
View
@@ -1 +1,3 @@
/dist
+*.hi
+*.o
@@ -6,7 +6,8 @@
-- Stability : Experimental
-- 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
@@ -16,12 +17,12 @@ import qualified Data.ByteString as B
import Data.Enumerator
-- | 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 build = continue (step build)
-
-step :: Monad m => (a -> Builder) -> Stream a -> Iteratee a m B.ByteString
-step build input = case input of
- EOF -> yield (B.empty) EOF
- Chunks [] -> continue (step build)
- Chunks (v:vs) -> yield (toByteString $ build v) (Chunks vs)
+iterBuilder builder = continue (step builder)
+ where
+ step :: Monad m => (a -> Builder) -> Stream a -> Iteratee a m B.ByteString
+ step b input = case input of
+ EOF -> yield (B.empty) EOF
+ Chunks [] -> continue (step b)
+ Chunks (v:vs) -> yield (toByteString $ b v) (Chunks vs)
View
25 LICENSE
@@ -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.
View
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
@@ -1,32 +1,34 @@
Name : blaze-builder-enumerator
Version : 0.1
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>
Maintainer : me@thomas-sutton.id.au
Copyright : Copyright (c) Thomas Sutton 2010
License : BSD3
+License-file : LICENSE
Build-type : Simple
Cabal-version : >=1.6
Category : Data, Text, Enumerator
Stability : Experimental
Bug-reports : mailto:me@thomas-sutton.id.au
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
- ghc-options: -Wall -fno-warn-unused-do-bind
-
- build-depends:
+ GHC-options: -Wall -fno-warn-unused-do-bind
+ Build-depends:
base >= 4 && < 5
, blaze-builder >= 0.2 && < 0.3
, bytestring >= 0.9 && < 0.10
, enumerator >= 0.4 && < 0.5
-
- exposed-modules:
- Blaze.ByteString.Builder.Enumerator
+ Exposed-modules:
+ Blaze.ByteString.Builder.Enumerator

0 comments on commit a361c2f

Please sign in to comment.