Sophie

Sophie

distrib > Fedora > 13 > x86_64 > by-pkgid > 0bcc8f6154ea6d133c0cb8193c49277b > files > 2

ghc-csv-doc-0.1.1-1.fc13.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--Rendered using the Haskell Html Library v0.2-->
<HTML
><HEAD
><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"
><TITLE
>Text.CSV</TITLE
><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"
><SCRIPT SRC="haddock-util.js" TYPE="text/javascript"
></SCRIPT
><SCRIPT TYPE="text/javascript"
>window.onload = function () {setSynopsis("mini_Text-CSV.html")};</SCRIPT
></HEAD
><BODY
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="topbar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><IMG SRC="haskell_icon.gif" WIDTH="16" HEIGHT="16" ALT=" "
></TD
><TD CLASS="title"
>csv-0.1.1: CSV loader and dumper</TD
><TD CLASS="topbut"
><A HREF="src/Text-CSV.html"
>Source code</A
></TD
><TD CLASS="topbut"
><A HREF="index.html"
>Contents</A
></TD
><TD CLASS="topbut"
><A HREF="doc-index.html"
>Index</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="modulebar"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD
><FONT SIZE="6"
>Text.CSV</FONT
></TD
><TD ALIGN="right"
><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="infohead"
>Portability</TD
><TD CLASS="infoval"
>ghc </TD
></TR
><TR
><TD CLASS="infohead"
>Stability</TD
><TD CLASS="infoval"
>provisional </TD
></TR
><TR
><TD CLASS="infohead"
>Maintainer</TD
><TD CLASS="infoval"
>Jaap Weel &lt;weel at ugcs dot caltech dot edu&gt; </TD
></TR
></TABLE
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Description</TD
></TR
><TR
><TD CLASS="doc"
><P
>This module parses and dumps documents that are formatted more or
   less according to RFC 4180, &quot;Common Format and MIME Type for
   Comma-Separated Values (CSV) Files&quot;,
   <A HREF="http://www.rfc-editor.org/rfc/rfc4180.txt"
>http://www.rfc-editor.org/rfc/rfc4180.txt</A
>.
</P
><P
>There are some issues with this RFC. I will describe what these
   issues are and how I deal with them.
</P
><P
>First, the RFC prescribes CRLF standard network line breaks, but
   you are likely to run across CSV files with other line endings, so
   we accept any sequence of CRs and LFs as a line break. 
</P
><P
>Second, there is an optional header line, but the format for the
   header line is exactly like a regular record and you can only
   figure out whether it exists from the mime type, which may not be
   available. I ignore the issues of header lines and simply turn them
   into regular records.
</P
><P
>Third, there is an inconsistency, in that the formal grammar
   specifies that fields can contain only certain US ASCII characters,
   but the specification of the MIME type allows for other character
   sets. I will allow all characters in fields, except for commas, CRs
   and LFs in unquoted fields. This should make it possible to parse
   CSV files in any encoding, but it allows for characters such as
   tabs that the RFC may be interpreted to forbid even in non-US-ASCII
   character sets. 
</P
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Synopsis</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>type</SPAN
> <A HREF="#t%3ACSV"
>CSV</A
> = [<A HREF="Text-CSV.html#t%3ARecord"
>Record</A
>]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>type</SPAN
> <A HREF="#t%3ARecord"
>Record</A
> = [<A HREF="Text-CSV.html#t%3AField"
>Field</A
>]</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>type</SPAN
> <A HREF="#t%3AField"
>Field</A
> = <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Acsv"
>csv</A
> :: <A HREF="/usr/share/doc/ghc/html/libraries/parsec-2.1.0.1/Text-ParserCombinators-Parsec-Prim.html#t%3AParser"
>Parser</A
> <A HREF="Text-CSV.html#t%3ACSV"
>CSV</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AparseCSV"
>parseCSV</A
> :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath"
>FilePath</A
> -&gt; <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Either.html#t%3AEither"
>Either</A
> <A HREF="/usr/share/doc/ghc/html/libraries/parsec-2.1.0.1/Text-ParserCombinators-Parsec-Error.html#t%3AParseError"
>ParseError</A
> <A HREF="Text-CSV.html#t%3ACSV"
>CSV</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AparseCSVFromFile"
>parseCSVFromFile</A
> :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath"
>FilePath</A
> -&gt; <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO"
>IO</A
> (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Either.html#t%3AEither"
>Either</A
> <A HREF="/usr/share/doc/ghc/html/libraries/parsec-2.1.0.1/Text-ParserCombinators-Parsec-Error.html#t%3AParseError"
>ParseError</A
> <A HREF="Text-CSV.html#t%3ACSV"
>CSV</A
>)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AparseCSVTest"
>parseCSVTest</A
> :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO"
>IO</A
> <A HREF="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29"
>()</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AprintCSV"
>printCSV</A
> :: <A HREF="Text-CSV.html#t%3ACSV"
>CSV</A
> -&gt; <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString"
>String</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Documentation</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><SPAN CLASS="keyword"
>type</SPAN
> <A NAME="t:CSV"
><A NAME="t%3ACSV"
></A
></A
><B
>CSV</B
> = [<A HREF="Text-CSV.html#t%3ARecord"
>Record</A
>]</TD
><TD CLASS="declbut"
><A HREF="src/Text-CSV.html#CSV"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>A CSV file is a series of records. According to the RFC, the
 records all have to have the same length. As an extension, I
 allow variable length records.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><SPAN CLASS="keyword"
>type</SPAN
> <A NAME="t:Record"
><A NAME="t%3ARecord"
></A
></A
><B
>Record</B
> = [<A HREF="Text-CSV.html#t%3AField"
>Field</A
>]</TD
><TD CLASS="declbut"
><A HREF="src/Text-CSV.html#Record"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>A record is a series of fields
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><SPAN CLASS="keyword"
>type</SPAN
> <A NAME="t:Field"
><A NAME="t%3AField"
></A
></A
><B
>Field</B
> = <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString"
>String</A
></TD
><TD CLASS="declbut"
><A HREF="src/Text-CSV.html#Field"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>A field is a string
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:csv"
><A NAME="v%3Acsv"
></A
></A
><B
>csv</B
> :: <A HREF="/usr/share/doc/ghc/html/libraries/parsec-2.1.0.1/Text-ParserCombinators-Parsec-Prim.html#t%3AParser"
>Parser</A
> <A HREF="Text-CSV.html#t%3ACSV"
>CSV</A
></TD
><TD CLASS="declbut"
><A HREF="src/Text-CSV.html#csv"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>A Parsec parser for parsing CSV files
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:parseCSV"
><A NAME="v%3AparseCSV"
></A
></A
><B
>parseCSV</B
> :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath"
>FilePath</A
> -&gt; <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Either.html#t%3AEither"
>Either</A
> <A HREF="/usr/share/doc/ghc/html/libraries/parsec-2.1.0.1/Text-ParserCombinators-Parsec-Error.html#t%3AParseError"
>ParseError</A
> <A HREF="Text-CSV.html#t%3ACSV"
>CSV</A
></TD
><TD CLASS="declbut"
><A HREF="src/Text-CSV.html#parseCSV"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Given a file name (used only for error messages) and a string to
 parse, run the parser.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:parseCSVFromFile"
><A NAME="v%3AparseCSVFromFile"
></A
></A
><B
>parseCSVFromFile</B
> :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AFilePath"
>FilePath</A
> -&gt; <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO"
>IO</A
> (<A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Either.html#t%3AEither"
>Either</A
> <A HREF="/usr/share/doc/ghc/html/libraries/parsec-2.1.0.1/Text-ParserCombinators-Parsec-Error.html#t%3AParseError"
>ParseError</A
> <A HREF="Text-CSV.html#t%3ACSV"
>CSV</A
>)</TD
><TD CLASS="declbut"
><A HREF="src/Text-CSV.html#parseCSVFromFile"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Given a file name, read from that file and run the parser
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:parseCSVTest"
><A NAME="v%3AparseCSVTest"
></A
></A
><B
>parseCSVTest</B
> :: <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/System-IO.html#t%3AIO"
>IO</A
> <A HREF="/usr/share/doc/ghc/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html#t%3A%28%29"
>()</A
></TD
><TD CLASS="declbut"
><A HREF="src/Text-CSV.html#parseCSVTest"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Given a string, run the parser, and print the result on stdout.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="topdecl"
><TABLE CLASS="declbar"
><TR
><TD CLASS="declname"
><A NAME="v:printCSV"
><A NAME="v%3AprintCSV"
></A
></A
><B
>printCSV</B
> :: <A HREF="Text-CSV.html#t%3ACSV"
>CSV</A
> -&gt; <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString"
>String</A
></TD
><TD CLASS="declbut"
><A HREF="src/Text-CSV.html#printCSV"
>Source</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="doc"
>Given an object of type CSV, generate a CSV formatted
 string. Always uses escaped fields.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="botbar"
>Produced by <A HREF="http://www.haskell.org/haddock/"
>Haddock</A
> version 2.6.0</TD
></TR
></TABLE
></BODY
></HTML
>