Sophie

Sophie

distrib > Mandriva > 2010.1 > x86_64 > media > contrib-release > by-pkgid > 51057bcd013d992f61ce4c2b0a4565e3 > files > 150

haskell-hxt-8.3.2-1mdv2010.1.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
>Data.Atom</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_Data-Atom.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"
>hxt-8.3.2: A collection of tools for processing XML with Haskell.</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"
>Data.Atom</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"
>Uwe Schmidt (uwe\@fh-wedel.de)</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"
>Atom objects
</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
>Unique Atoms generated from Strings and
   managed as flyweights
</P
><P
>Data.Atom can be used for caching and storage optimisation
   of frequently used strings. An <TT
>Atom</TT
> is constructed from a <TT
>String</TT
>.
   For two equal strings the identical atom is returned.
</P
><P
>This module can be used for optimizing memory usage when working with
   strings or names. Many applications use data types like
   <TT
>Map String SomeAttribute</TT
> where a rather fixed set of keys is used.
   Especially XML applications often work with a limited set of element and attribute names.
   For these applications it becomes more memory efficient when working with types like
   <TT
>Map Atom SomeAttribute</TT
> and convert the keys into atoms before operating
   on such a map.
</P
><P
>Internally this module manages a map of atoms. The atoms are internally represented
   by <TT
>ByteString</TT
>s. When creating a new atom from a string, the string is first converted
   into an UTF8 <TT
>Word8</TT
> sequence, which is packed into a <TT
>ByteString</TT
>. This <TT
>ByteString</TT
> is looked
   up in the table of atoms. If it is already there, the value in the map is used as atom, else
   the new <TT
>ByteString</TT
> is inserted into the map.
</P
><P
>Of course the implementation of this name cache uses <TT
>unsavePerformIO</TT
> and <TT
>MVar</TT
>s
   for managing this kind of global state.
</P
><P
>The following laws hold for atoms
</P
><PRE
>
 s  ==       t =&gt; newAtom s  ==       newAtom t
 s `compare` t =&gt; newAtom s `compare` newAtom t
 show . newAtom == id
</PRE
><P
>Equality test for <TT
>Atom</TT
>s runs in <EM
>O(1)</EM
>, it is just a pointer comarison.
   The <TT
>Ord</TT
> comparisons have the same runtime like the <TT
>ByteString</TT
> comparisons.
   Internally there is an UTF8 comparison, but UTF8 encoding preserves the total order.
</P
><P
>Warning: The internal cache never shrinks during execution. So using it in a
   undisciplined way can lead to memory leaks.
</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%3AAtom"
>Atom</A
> </TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AnewAtom"
>newAtom</A
> :: <A HREF="/usr/share/doc/ghc/libraries/base/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="Data-Atom.html#t%3AAtom"
>Atom</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Ashare"
>share</A
> :: <A HREF="/usr/share/doc/ghc/libraries/base/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="/usr/share/doc/ghc/libraries/base/Data-Char.html#t%3AString"
>String</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"
>Atom objects
</A
></A
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><SPAN CLASS="keyword"
>data</SPAN
>  <A NAME="t:Atom"
><A NAME="t%3AAtom"
></A
></A
><B
>Atom</B
>  </TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="section4"
><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Atom')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:Atom" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="/usr/share/doc/ghc/libraries/base/Data-Eq.html#t%3AEq"
>Eq</A
> <A HREF="Data-Atom.html#t%3AAtom"
>Atom</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="/usr/share/doc/ghc/libraries/base/Data-Ord.html#t%3AOrd"
>Ord</A
> <A HREF="Data-Atom.html#t%3AAtom"
>Atom</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="/usr/share/doc/ghc/libraries/base/Text-Read.html#t%3ARead"
>Read</A
> <A HREF="Data-Atom.html#t%3AAtom"
>Atom</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="/usr/share/doc/ghc/libraries/base/Text-Show.html#t%3AShow"
>Show</A
> <A HREF="Data-Atom.html#t%3AAtom"
>Atom</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="/usr/share/doc/ghc/libraries/base/Data-Typeable.html#t%3ATypeable"
>Typeable</A
> <A HREF="Data-Atom.html#t%3AAtom"
>Atom</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="/usr/share/doc/ghc/libraries/parallel/Control-Parallel-Strategies.html#t%3ANFData"
>NFData</A
> <A HREF="Data-Atom.html#t%3AAtom"
>Atom</A
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:newAtom"
><A NAME="v%3AnewAtom"
></A
></A
><B
>newAtom</B
> :: <A HREF="/usr/share/doc/ghc/libraries/base/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="Data-Atom.html#t%3AAtom"
>Atom</A
></TD
></TR
><TR
><TD CLASS="doc"
>creation of an <TT
>Atom</TT
> from a <TT
>String</TT
>
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v:share"
><A NAME="v%3Ashare"
></A
></A
><B
>share</B
> :: <A HREF="/usr/share/doc/ghc/libraries/base/Data-Char.html#t%3AString"
>String</A
> -&gt; <A HREF="/usr/share/doc/ghc/libraries/base/Data-Char.html#t%3AString"
>String</A
></TD
></TR
><TR
><TD CLASS="doc"
><P
>Insert a <TT
>String</TT
> into the atom cache and convert the atom back into a <TT
>String</TT
>.
</P
><P
>locically <TT
>share == id</TT
> holds, but internally equal strings share the same memory.
</P
></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.5.0</TD
></TR
></TABLE
></BODY
></HTML
>