Sophie

Sophie

distrib > Mageia > 5 > i586 > media > core-release > by-pkgid > 6e204a966e8c42d976f99a1700ce5f20 > files > 3710

ghc-7.4.2-4.mga5.i586.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>Data.Ix</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_Data-Ix.html");};
//]]>
</script></head><body><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption">haskell2010-1.1.0.1: Compatibility with Haskell 2010</p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>Safe</td></tr></table><p class="caption">Data.Ix</p></div><div id="table-of-contents"><p class="caption">Contents</p><ul><li><a href="#g:1">The <code><a href="Data-Ix.html#t:Ix">Ix</a></code> class
</a></li><li><a href="#g:2">Deriving Instances of <code>Ix</code>
</a></li></ul></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"><span class="keyword">class</span> <a href="Prelude.html#t:Ord">Ord</a> a =&gt; <a href="#t:Ix">Ix</a> a  <span class="keyword">where</span><ul class="subs"><li><a href="#v:range">range</a> :: (a, a) -&gt; [a]</li><li><a href="#v:index">index</a> :: (a, a) -&gt; a -&gt; <a href="Prelude.html#t:Int">Int</a></li><li><a href="#v:inRange">inRange</a> :: (a, a) -&gt; a -&gt; <a href="Prelude.html#t:Bool">Bool</a></li><li><a href="#v:rangeSize">rangeSize</a> :: (a, a) -&gt; <a href="Prelude.html#t:Int">Int</a></li></ul></li></ul></div><div id="interface"><h1 id="g:1">The <code><a href="Data-Ix.html#t:Ix">Ix</a></code> class
</h1><div class="top"><p class="src"><span class="keyword">class</span> <a href="Prelude.html#t:Ord">Ord</a> a =&gt; <a name="t:Ix" class="def">Ix</a> a  <span class="keyword">where</span><a href="../base-4.5.1.0/src/GHC-Arr.html#Ix" class="link">Source</a></p><div class="doc"><p>The <code><a href="Data-Ix.html#t:Ix">Ix</a></code> class is used to map a contiguous subrange of values in
 a type onto integers.  It is used primarily for array indexing
 (see the array package).
</p><p>The first argument <code>(l,u)</code> of each of these operations is a pair
 specifying the lower and upper bounds of a contiguous subrange of values.
</p><p>An implementation is entitled to assume the following laws about these
 operations:
</p><ul><li> <code><code><a href="Data-Ix.html#v:inRange">inRange</a></code> (l,u) i == <code><a href="Prelude.html#v:elem">elem</a></code> i (<code><a href="Data-Ix.html#v:range">range</a></code> (l,u))</code> <code> </code>
</li><li> <code><code><a href="Data-Ix.html#v:range">range</a></code> (l,u) <code><a href="Prelude.html#v:-33--33-">!!</a></code> <code><a href="Data-Ix.html#v:index">index</a></code> (l,u) i == i</code>, when <code><code><a href="Data-Ix.html#v:inRange">inRange</a></code> (l,u) i</code>
</li><li> <code><code><a href="Prelude.html#v:map">map</a></code> (<code><a href="Data-Ix.html#v:index">index</a></code> (l,u)) (<code><a href="Data-Ix.html#v:range">range</a></code> (l,u))) == [0..<code><a href="Data-Ix.html#v:rangeSize">rangeSize</a></code> (l,u)-1]</code> <code> </code>
</li><li> <code><code><a href="Data-Ix.html#v:rangeSize">rangeSize</a></code> (l,u) == <code><a href="Prelude.html#v:length">length</a></code> (<code><a href="Data-Ix.html#v:range">range</a></code> (l,u))</code> <code> </code>
</li></ul><p>Minimal complete instance: <code><a href="Data-Ix.html#v:range">range</a></code>, <code><a href="Data-Ix.html#v:index">index</a></code> and <code><a href="Data-Ix.html#v:inRange">inRange</a></code>.
</p></div><div class="subs methods"><p class="caption">Methods</p><p class="src"><a name="v:range" class="def">range</a> :: (a, a) -&gt; [a]<a href="../base-4.5.1.0/src/GHC-Arr.html#range" class="link">Source</a></p><div class="doc"><p>The list of values in the subrange defined by a bounding pair.
</p></div><p class="src"><a name="v:index" class="def">index</a> :: (a, a) -&gt; a -&gt; <a href="Prelude.html#t:Int">Int</a><a href="../base-4.5.1.0/src/GHC-Arr.html#index" class="link">Source</a></p><div class="doc"><p>The position of a subscript in the subrange.
</p></div><p class="src"><a name="v:inRange" class="def">inRange</a> :: (a, a) -&gt; a -&gt; <a href="Prelude.html#t:Bool">Bool</a><a href="../base-4.5.1.0/src/GHC-Arr.html#inRange" class="link">Source</a></p><div class="doc"><p>Returns <code><a href="Prelude.html#v:True">True</a></code> the given subscript lies in the range defined
 the bounding pair.
</p></div><p class="src"><a name="v:rangeSize" class="def">rangeSize</a> :: (a, a) -&gt; <a href="Prelude.html#t:Int">Int</a><a href="../base-4.5.1.0/src/GHC-Arr.html#rangeSize" class="link">Source</a></p><div class="doc"><p>The size of the subrange defined by a bounding pair.
</p></div></div><div class="subs instances"><p id="control.i:Ix" class="caption collapser" onclick="toggleSection('i:Ix')">Instances</p><div id="section.i:Ix" class="show"><table><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Prelude.html#t:Bool">Bool</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Prelude.html#t:Char">Char</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Prelude.html#t:Int">Int</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Data-Int.html#t:Int8">Int8</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Data-Int.html#t:Int16">Int16</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Data-Int.html#t:Int32">Int32</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Data-Int.html#t:Int64">Int64</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Prelude.html#t:Integer">Integer</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Prelude.html#t:Ordering">Ordering</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Data-Word.html#t:Word">Word</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Data-Word.html#t:Word8">Word8</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Data-Word.html#t:Word16">Word16</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Data-Word.html#t:Word32">Word32</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Data-Word.html#t:Word64">Word64</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> ()</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="Data-Char.html#t:GeneralCategory">GeneralCategory</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="System-IO.html#t:SeekMode">SeekMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src"><a href="Data-Ix.html#t:Ix">Ix</a> <a href="System-IO.html#t:IOMode">IOMode</a></td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Data-Ix.html#t:Ix">Ix</a> a, <a href="Data-Ix.html#t:Ix">Ix</a> b) =&gt; <a href="Data-Ix.html#t:Ix">Ix</a> (a, b)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Data-Ix.html#t:Ix">Ix</a> a1, <a href="Data-Ix.html#t:Ix">Ix</a> a2, <a href="Data-Ix.html#t:Ix">Ix</a> a3) =&gt; <a href="Data-Ix.html#t:Ix">Ix</a> (a1, a2, a3)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Data-Ix.html#t:Ix">Ix</a> a1, <a href="Data-Ix.html#t:Ix">Ix</a> a2, <a href="Data-Ix.html#t:Ix">Ix</a> a3, <a href="Data-Ix.html#t:Ix">Ix</a> a4) =&gt; <a href="Data-Ix.html#t:Ix">Ix</a> (a1, a2, a3, a4)</td><td class="doc empty">&nbsp;</td></tr><tr><td class="src">(<a href="Data-Ix.html#t:Ix">Ix</a> a1, <a href="Data-Ix.html#t:Ix">Ix</a> a2, <a href="Data-Ix.html#t:Ix">Ix</a> a3, <a href="Data-Ix.html#t:Ix">Ix</a> a4, <a href="Data-Ix.html#t:Ix">Ix</a> a5) =&gt; <a href="Data-Ix.html#t:Ix">Ix</a> (a1, a2, a3, a4, a5)</td><td class="doc empty">&nbsp;</td></tr></table></div></div></div><h1 id="g:2">Deriving Instances of <code>Ix</code>
</h1><div class="doc"><p>It is possible to derive an instance of <code>Ix</code> automatically, using
a <code>deriving</code> clause on a <code>data</code> declaration.
Such derived instance declarations for the class <code>Ix</code> are only possible
for enumerations (i.e. datatypes having
only nullary constructors) and single-constructor datatypes,
whose constituent types are instances of <code>Ix</code>.   A Haskell implementation
must provide <code>Ix</code> instances for tuples up to at least size 15.
</p><p>For an <em>enumeration</em>, the nullary constructors are assumed to be
numbered left-to-right with the indices being 0 to n-1 inclusive.
This is the same numbering defined by the <code>Enum</code> class.  For example,
given the datatype:
</p><pre> data Colour = Red | Orange | Yellow | Green | Blue | Indigo | Violet
</pre><p>we would have:
</p><pre> range   (Yellow,Blue)        ==  [Yellow,Green,Blue]
 index   (Yellow,Blue) Green  ==  1
 inRange (Yellow,Blue) Red    ==  False
</pre><p>For <em>single-constructor datatypes</em>, the derived instance declarations
are as shown for tuples:
</p><pre> instance  (Ix a, Ix b)  =&gt; Ix (a,b) where
         range ((l,l'),(u,u'))
                 = [(i,i') | i &lt;- range (l,u), i' &lt;- range (l',u')]
         index ((l,l'),(u,u')) (i,i')
                 =  index (l,u) i * rangeSize (l',u') + index (l',u') i'
         inRange ((l,l'),(u,u')) (i,i')
                 = inRange (l,u) i &amp;&amp; inRange (l',u') i'
 
 -- Instances for other tuples are obtained from this scheme:
 --
 --  instance  (Ix a1, Ix a2, ... , Ix ak) =&gt; Ix (a1,a2,...,ak)  where
 --      range ((l1,l2,...,lk),(u1,u2,...,uk)) =
 --          [(i1,i2,...,ik) | i1 &lt;- range (l1,u1),
 --                            i2 &lt;- range (l2,u2),
 --                            ...
 --                            ik &lt;- range (lk,uk)]
 --
 --      index ((l1,l2,...,lk),(u1,u2,...,uk)) (i1,i2,...,ik) =
 --        index (lk,uk) ik + rangeSize (lk,uk) * (
 --         index (lk-1,uk-1) ik-1 + rangeSize (lk-1,uk-1) * (
 --          ...
 --           index (l1,u1)))
 --
 --      inRange ((l1,l2,...lk),(u1,u2,...,uk)) (i1,i2,...,ik) =
 --          inRange (l1,u1) i1 &amp;&amp; inRange (l2,u2) i2 &amp;&amp;
 --              ... &amp;&amp; inRange (lk,uk) ik
</pre></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.11.0</p></div></body></html>