packages feed

quiver-cell (empty) → 0.0.0.1

raw patch · 4 files changed

+122/−0 lines, 4 filesdep +basedep +data-celldep +quiversetup-changed

Dependencies added: base, data-cell, quiver

Files

+ LICENSE view
@@ -0,0 +1,28 @@++  Quiver combinators for cellular data processing+  ===============================================++    Copyright © 2015 Patryk Zadarnowski «pat@jantar.org».+    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. ➂ The name of any+  author may not be used to endorse or promote products derived from this+  software without their specific prior written permission.++  THIS SOFTWARE IS PROVIDED “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 AUTHORS 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.+
+ Setup.hs view
@@ -0,0 +1,3 @@+#! /usr/bin/env runhaskell+import Distribution.Simple+main = defaultMain
+ quiver-cell.cabal view
@@ -0,0 +1,44 @@+name:           quiver-cell+version:        0.0.0.1+synopsis:       Quiver combinators for cellular data processing+homepage:       https://github.com/zadarnowski/quiver-cell+category:       Control+stability:      alpha++author:         Patryk Zadarnowski+maintainer:     Patryk Zadarnowski <pat@jantar.org>++copyright:      Copyright (c) 2015 Patryk Zadarnowski++description:++    This library provides combinators for Quiver-based streaming+    of cellular data, i.e., tabular data encoded as a stream of+    optionally-fragmented cell values.++cabal-version:  >= 1.18+build-type:     Simple+license:        BSD3+license-file:   LICENSE++source-repository head+  type:         git+  location:     https://github.com/zadarnowski/quiver-cell.git++source-repository this+  type:         git+  location:     https://github.com/zadarnowski/quiver-cell.git+  tag:          0.0.0.1++library+  hs-source-dirs:   src+  default-language: Haskell2010+  ghc-options:      -Wall -fno-warn-unused-do-bind -fno-warn-missing-signatures++  exposed-modules:+    Control.Quiver.Cell++  build-depends:+    base                    >= 4.8 && < 5,+    data-cell               >= 1.0.0.2,+    quiver                  >= 0.0.0.6
+ src/Control/Quiver/Cell.lhs view
@@ -0,0 +1,47 @@+> -- | Module:    Control.Quiver.Cell+> -- Description: Convertions between cell-based and row-based representations of tabular data+> -- Copyright:   © 2015 Patryk Zadarnowski <pat@jantar.org>+> -- License:     BSD3+> -- Maintainer:  pat@jantar.org+> -- Stability:   experimental+> -- Portability: portable+> --+> -- Quiver processors converting between cellular and traditional tabular data.++> module Control.Quiver.Cell (+>   toRows, fromRows,+> ) where++> import Data.Cell+> import Control.Quiver++> -- | A simple Quiver processor that converts a stream of cells into a stream of rows,+> --   with each row represented by a non-empty list of cell values.++> toRows :: (Monoid a) => SP (Cell a) [a] f ()+> toRows = loop0+>  where+>   loop0 = loop1 [] []+>   loop1 row cell = consume () (loop2 row cell) (emit_ (assemble row cell))+>   loop2 row cell (Cell part d) =+>     case d of+>       EOP -> loop1 row cell'+>       EOC -> loop1 (mconcat (reverse cell') : row) []+>       _   -> produce (assemble row cell') (const $ loop0) (deliver ())+>    where+>     cell' = part:cell+>   assemble row cell = reverse (mconcat (reverse cell) : row)++> -- | A simple Quiver processor that converts a stream of rows to a stream of cells,+> --   In this version, the final cell in the table is not marked with @EOT@ to avoid+> --   the need for row lookahead, delivering the list of any cells that could not+> --   be produced from the final consumed row.+> --+> --   Empty input rows are ignored.++> fromRows :: SP [a] (Cell a) f [a]+> fromRows = loop0+>  where+>   loop0 = consume () loop1 (deliver [])+>   loop1 (x:xs) = produce (Cell x (if null xs then EOR else EOC)) (const $ loop1 xs) (deliver xs)+>   loop1 [] = loop0