Permalink
Browse files

Initial import

  • Loading branch information...
0 parents commit 6f8aacf3d1aaecf9ad9bd6d9c553cd23501c7080 @tibbe committed Mar 20, 2012
Showing with 86 additions and 0 deletions.
  1. +30 −0 Data/Sea.hs
  2. +30 −0 LICENSE
  3. +2 −0 Setup.hs
  4. +24 −0 sea.cabal
@@ -0,0 +1,30 @@
+-- | A RFC 4180 compliant CSV parsing and encodig module.
+module Data.Sea where
+
+import Control.Applicative
+import Data.Attoparsec.Char8
+import qualified Data.Attoparsec.Lazy as L
+import Data.Vector as Vector hiding ((++))
+
+decode s = case L.parse csv s of
+ L.Done _ v -> Just v
+ _ -> Nothing
+
+csv = do
+ vals <- record `sepBy` endOfLine
+ optional endOfLine
+ endOfInput
+ return (Vector.fromList vals)
+
+record = Vector.fromList <$> field `sepBy` comma
+
+field = do
+ c <- anyChar
+ case c of
+ '"' -> escapedField
+ _ -> unescapedField
+
+escapedField = undefined
+unescapedField = takeTill (\ c -> c == ',' || c == '\r' || c == '\n')
+
+comma = char ','
30 LICENSE
@@ -0,0 +1,30 @@
+Copyright (c)2012, Johan Tibell
+
+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.
+
+ * Neither the name of Johan Tibell nor the names of other
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"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
+OWNER OR CONTRIBUTORS 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.
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
@@ -0,0 +1,24 @@
+Name: sea
+Version: 0.1.0.0
+Synopsis: A CSV parsing and encoding library
+Description:
+ A CSV parsing and encoding library optimized for ease of use and high
+ performance.
+Homepage: https://github.com/tibbe/sea
+License: BSD3
+License-file: LICENSE
+Author: Johan Tibell
+Maintainer: johan.tibell@gmail.com
+Category: Text, Web, CSV
+Build-type: Simple
+Cabal-version: >=1.2
+
+
+Library
+ Exposed-modules: Data.Sea
+
+ Build-depends: attoparsec,
+ base,
+ vector
+
+ -- Other-modules:

0 comments on commit 6f8aacf

Please sign in to comment.