Permalink
Browse files

Documentation improvements

  • Loading branch information...
1 parent 4d255b8 commit 76cdc0afbc0b402aa70e9efe48d50bb422a7e469 @tibbe tibbe committed Nov 17, 2012
Showing with 24 additions and 0 deletions.
  1. +24 −0 Data/Csv.hs
View
@@ -14,6 +14,9 @@ module Data.Csv
-- * Usage example
-- $example
+ -- * Treating CSV data as opaque byte strings
+ -- $generic-processing
+
-- * Encoding and decoding
-- $encoding
decode
@@ -88,6 +91,27 @@ import Data.Csv.Types
-- @ >>> 'decode' 'False' \"John,27\\r\\nJane,28\\r\\n\" :: Either String (Vector (Text, Int))
-- Right (fromList [(\"John\",27),(\"Jane\",28)])
-- @
+--
+-- We pass 'False' as the first argument to indicate that the CSV
+-- input data isn't preceded by a header.
+--
+-- In practice, the return type of 'decode' rarely needs to be given,
+-- as it can often be inferred from the context.
+
+-- $generic-processing
+--
+-- Sometimes you might want to work with a CSV file which contents is
+-- unknown to you. For example, you might want remove the second
+-- column of a file without knowing anything about its content. To
+-- parse a CSV file to a generic representation, just convert each
+-- record to a @'Vector' 'ByteString'@ value, like so:
+--
+-- @ 'decode' 'False' \"John,27\\r\\nJane,28\\r\\n\" :: Either String (Vector (Vector ByteString))
+-- Right (fromList [fromList [\"John\",\"27\"],fromList [\"Jane\",\"28\"]])
+-- @
+--
+-- As the example output above shows, all the fields are returned as
+-- uninterpreted 'ByteString' values.
-- $encoding
--

0 comments on commit 76cdc0a

Please sign in to comment.