Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 77f0c8b2568c8ba86bf4498d38e7ecdc > files > 824

ghc-base-devel-4.2.0.2-8.6.fc14.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
>System.Mem.StableName</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_System-Mem-StableName.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"
>base-4.2.0.2: Basic libraries</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"
>System.Mem.StableName</FONT
></TD
><TD ALIGN="right"
><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="infohead"
>Portability</TD
><TD CLASS="infoval"
>non-portable</TD
></TR
><TR
><TD CLASS="infohead"
>Stability</TD
><TD CLASS="infoval"
>experimental</TD
></TR
><TR
><TD CLASS="infohead"
>Maintainer</TD
><TD CLASS="infoval"
>libraries@haskell.org</TD
></TR
></TABLE
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="section4"
><B
>Contents</B
></TD
></TR
><TR
><TD
><DL
><DT
><A HREF="#1"
>Stable Names
</A
></DT
></DL
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Description</TD
></TR
><TR
><TD CLASS="doc"
><P
>Stable names are a way of performing fast (O(1)), not-quite-exact
 comparison between objects.
</P
><P
>Stable names solve the following problem: suppose you want to build
 a hash table with Haskell objects as keys, but you want to use
 pointer equality for comparison; maybe because the keys are large
 and hashing would be slow, or perhaps because the keys are infinite
 in size.  We can't build a hash table using the address of the
 object as the key, because objects get moved around by the garbage
 collector, meaning a re-hash would be necessary after every garbage
 collection.
</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"
>data</SPAN
>  <A HREF="#t%3AStableName"
>StableName</A
> a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AmakeStableName"
>makeStableName</A
> ::  a -&gt; <A HREF="System-IO.html#t%3AIO"
>IO</A
> (<A HREF="System-Mem-StableName.html#t%3AStableName"
>StableName</A
> a)</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AhashStableName"
>hashStableName</A
> ::  <A HREF="System-Mem-StableName.html#t%3AStableName"
>StableName</A
> a -&gt; <A HREF="Data-Int.html#t%3AInt"
>Int</A
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
><A NAME="1"
><A NAME="1"
>Stable Names
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>data</SPAN
>  <A NAME="t:StableName"
><A NAME="t%3AStableName"
></A
></A
><B
>StableName</B
> a </TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="ndoc"
><P
>An abstract name for an object, that supports equality and hashing.
</P
><P
>Stable names have the following property:
</P
><UL
><LI
> If <TT
>sn1 :: StableName</TT
> and <TT
>sn2 :: StableName</TT
> and <TT
>sn1 == sn2</TT
>
   then <TT
>sn1</TT
> and <TT
>sn2</TT
> were created by calls to <TT
>makeStableName</TT
> on 
   the same object.
</LI
></UL
><P
>The reverse is not necessarily true: if two stable names are not
  equal, then the objects they name may still be equal.  Note in particular
  that mkStableName may return a different <TT
><A HREF="System-Mem-StableName.html#t%3AStableName"
>StableName</A
></TT
> after an
  object is evaluated.
</P
><P
>Stable Names are similar to Stable Pointers (<A HREF="Foreign-StablePtr.html"
>Foreign.StablePtr</A
>),
  but differ in the following ways:
</P
><UL
><LI
> There is no <TT
>freeStableName</TT
> operation, unlike <A HREF="Foreign-StablePtr.html"
>Foreign.StablePtr</A
>s.
    Stable names are reclaimed by the runtime system when they are no
    longer needed.
</LI
><LI
> There is no <TT
>deRefStableName</TT
> operation.  You can't get back from
    a stable name to the original Haskell object.  The reason for
    this is that the existence of a stable name for an object does not
    guarantee the existence of the object itself; it can still be garbage
    collected.
</LI
></UL
></TD
></TR
><TR
><TD CLASS="section4"
><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:StableName')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:StableName" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="Data-Typeable.html#t%3ATypeable1"
>Typeable1</A
> <A HREF="System-Mem-StableName.html#t%3AStableName"
>StableName</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="Data-Eq.html#t%3AEq"
>Eq</A
> (<A HREF="System-Mem-StableName.html#t%3AStableName"
>StableName</A
> a)</TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:makeStableName"
><A NAME="v%3AmakeStableName"
></A
></A
><B
>makeStableName</B
> ::  a -&gt; <A HREF="System-IO.html#t%3AIO"
>IO</A
> (<A HREF="System-Mem-StableName.html#t%3AStableName"
>StableName</A
> a)</TD
></TR
><TR
><TD CLASS="doc"
>Makes a <TT
><A HREF="System-Mem-StableName.html#t%3AStableName"
>StableName</A
></TT
> for an arbitrary object.  The object passed as
 the first argument is not evaluated by <TT
><A HREF="System-Mem-StableName.html#v%3AmakeStableName"
>makeStableName</A
></TT
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:hashStableName"
><A NAME="v%3AhashStableName"
></A
></A
><B
>hashStableName</B
> ::  <A HREF="System-Mem-StableName.html#t%3AStableName"
>StableName</A
> a -&gt; <A HREF="Data-Int.html#t%3AInt"
>Int</A
></TD
></TR
><TR
><TD CLASS="doc"
>Convert a <TT
><A HREF="System-Mem-StableName.html#t%3AStableName"
>StableName</A
></TT
> to an <TT
><A HREF="Data-Int.html#t%3AInt"
>Int</A
></TT
>.  The <TT
><A HREF="Data-Int.html#t%3AInt"
>Int</A
></TT
> returned is not
 necessarily unique; several <TT
><A HREF="System-Mem-StableName.html#t%3AStableName"
>StableName</A
></TT
>s may map to the same <TT
><A HREF="Data-Int.html#t%3AInt"
>Int</A
></TT
>
 (in practice however, the chances of this are small, so the result
 of <TT
><A HREF="System-Mem-StableName.html#v%3AhashStableName"
>hashStableName</A
></TT
> makes a good hash key).
</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.1</TD
></TR
></TABLE
></BODY
></HTML
>