Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > db7a4a658d190b3e658423135710c498 > files > 564

ghc-darcs-devel-2.8.3-1.fc18.i686.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>CommandLine</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_CommandLine.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="src/CommandLine.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">darcs-2.8.3: a distributed, interactive, smart revision control system</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Portability</th><td>portable</td></tr><tr><th>Stability</th><td>experimental</td></tr><tr><th>Maintainer</th><td>darcs-devel@darcs.net</td></tr><tr><th>Safe Haskell</th><td>Safe-Infered</td></tr></table><p class="caption">CommandLine</p></div><div id="description"><p class="caption">Description</p><div 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="%&lt;.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></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:parseCmd">parseCmd</a> :: FTable -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-String.html#t:String">String</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/parsec-3.1.2/Text-Parsec-Error.html#t:ParseError">ParseError</a> ([<a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-String.html#t:String">String</a>], <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>)</li><li class="src short"><a href="#v:addUrlencoded">addUrlencoded</a> :: FTable -&gt; FTable</li></ul></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a name="v:parseCmd" class="def">parseCmd</a> :: FTable -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-String.html#t:String">String</a> -&gt; <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Either.html#t:Either">Either</a> <a href="/usr/share/doc/ghc/html/libraries/parsec-3.1.2/Text-Parsec-Error.html#t:ParseError">ParseError</a> ([<a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-String.html#t:String">String</a>], <a href="/usr/share/doc/ghc/html/libraries/base-4.5.0.0/Data-Bool.html#t:Bool">Bool</a>)<a href="src/CommandLine.html#parseCmd" class="link">Source</a></p><div class="doc"><p>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
 [(<code>s</code>,<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>
</p></div></div><div class="top"><p class="src"><a name="v:addUrlencoded" class="def">addUrlencoded</a> :: FTable -&gt; FTable<a href="src/CommandLine.html#addUrlencoded" class="link">Source</a></p><div class="doc"><p>for every mapping (c,s), add a mapping with uppercase c
 and the urlencoded string s
</p></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.10.0</p></div></body></html>