Sophie

Sophie

distrib > Fedora > 13 > i386 > media > updates > by-pkgid > b0c98c29aff20adb5ac5f9eed34fc595 > files > 3

ghc-darcs-doc-2.4.4-1.fc13.i686.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
>CommandLine</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_CommandLine.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"
>darcs-2.4.4: a distributed, interactive, smart revision control system</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"
>CommandLine</FONT
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Description</TD
></TR
><TR
><TD CLASS="doc"
><P
>A parser for commandlines, returns an arg list and expands
 format strings given in a translation table. Additionally
 the commandline can end with <A HREF="%<.html"
>%&lt;</A
> specifying that the command
 expects input on stdin.
</P
><P
>Some tests for the parser.
</P
><PRE
> formatTable = [('s',&quot;&lt;insert subject here&gt;&quot;),
                ('a',&quot;&lt;insert author here&gt;&quot;)]

 testParser :: (Show a, Eq a) =&gt; Parser a -&gt; String -&gt; a -&gt; a
 testParser p s ok = case parse p &quot;&quot; s of
                     Left e -&gt; error $ &quot;Parser failed with: &quot; ++ (show e)
                     Right res -&gt; if res == ok
                                  then res
                                  else error $ &quot;Parser failed: got &quot;
                                         ++ (show res) ++ &quot;, expected &quot;
                                         ++ (show ok)

 testCases = [(&quot;a b&quot;,([&quot;a&quot;,&quot;b&quot;], False)),
              (&quot;a b %&lt;&quot;,([&quot;a&quot;,&quot;b&quot;], True)),
              (&quot;a b %&lt; &quot;,([&quot;a&quot;,&quot;b&quot;], True)),
              (&quot;\&quot;arg0 contains spaces \\\&quot;quotes\\\&quot;\&quot; b&quot;,
               ([&quot;arg0 contains spaces \&quot;quotes\&quot;&quot;,&quot;b&quot;],False)),
              (&quot;a %s %&lt;&quot;,([&quot;a&quot;,&quot;&lt;insert subject here&gt;&quot;], True))]

 runTests = map (uncurry $ testParser (commandline formatTable)) testCases
</PRE
></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"
><A HREF="#v%3AparseCmd"
>parseCmd</A
> :: FTable -&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="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString"
>String</A
>], <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Bool.html#t%3ABool"
>Bool</A
>)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AaddUrlencoded"
>addUrlencoded</A
> :: FTable -&gt; FTable</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="decl"
><A NAME="v:parseCmd"
><A NAME="v%3AparseCmd"
></A
></A
><B
>parseCmd</B
> :: FTable -&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="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Char.html#t%3AString"
>String</A
>], <A HREF="/usr/share/doc/ghc/html/libraries/base-4.2.0.0/Data-Bool.html#t%3ABool"
>Bool</A
>)</TD
></TR
><TR
><TD CLASS="doc"
>parse a commandline returning a list of strings 
 (intended to be used as argv) and a bool value which
 specifies if the command expects input on stdin
 format specifiers with a mapping in ftable are accepted
 and replaced by the given strings. E.g. if the ftable is
 [(s,<A HREF="Some subject.html"
>Some subject</A
>)], then <A HREF="%s.html"
>%s</A
> is replaced by <A HREF="Some subject.html"
>Some subject</A
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:addUrlencoded"
><A NAME="v%3AaddUrlencoded"
></A
></A
><B
>addUrlencoded</B
> :: FTable -&gt; FTable</TD
></TR
><TR
><TD CLASS="doc"
>for every mapping (c,s), add a mapping with uppercase c
 and the urlencoded string s
</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
>