packages feed

ChasingBottoms-1.2.2: docs/Test-ChasingBottoms-Nat.html

<!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
>Test.ChasingBottoms.Nat</TITLE
><LINK HREF="haddock.css" REL="stylesheet" TYPE="text/css"
><SCRIPT SRC="haddock.js" TYPE="text/javascript"
></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"
>Chasing Bottoms</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"
>Test.ChasingBottoms.Nat</FONT
></TD
><TD ALIGN="right"
><TABLE CLASS="narrow" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="infohead"
>Portability</TD
><TD CLASS="infoval"
>non-portable (GHC-specific)</TD
></TR
><TR
><TD CLASS="infohead"
>Stability</TD
><TD CLASS="infoval"
>experimental</TD
></TR
><TR
><TD CLASS="infohead"
>Maintainer</TD
><TD CLASS="infoval"
>http://www.cs.chalmers.se/~nad/</TD
></TR
></TABLE
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="section1"
>Description</TD
></TR
><TR
><TD CLASS="doc"
>A simple implementation of natural numbers on top of <TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Prelude.html#t%3AInteger"
>Integer</A
></TT
>s.
 Note that since <TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Prelude.html#t%3AInteger"
>Integer</A
></TT
>s are used there is no infinite natural
 number; in other words, <TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Prelude.html#v%3Asucc"
>succ</A
></TT
> is strict.
</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%3ANat"
>Nat</A
> </TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AisSucc"
>isSucc</A
> :: <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
> -&gt; <A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Bool.html#t%3ABool"
>Bool</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AfromSucc"
>fromSucc</A
> :: <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
> -&gt; <A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Maybe.html#t%3AMaybe"
>Maybe</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3Anatrec"
>natrec</A
> :: a -&gt; (<A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
> -&gt; a -&gt; a) -&gt; <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="s8"
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="#v%3AfoldN"
>foldN</A
> :: a -&gt; (a -&gt; a) -&gt; <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
> -&gt; a</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"
><SPAN CLASS="keyword"
>data</SPAN
> <A NAME="t%3ANat"
></A
><B
>Nat</B
> </TD
></TR
><TR
><TD CLASS="body"
><TABLE CLASS="vanilla" CELLSPACING="0" CELLPADDING="0"
><TR
><TD CLASS="ndoc"
><P
>Natural numbers.
</P
><P
>No <TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Generics-Basics.html#t%3AData"
>Data</A
></TT
> instance is provided since the
 implementation should be abstract.
</P
></TD
></TR
><TR
><TD CLASS="section4"
><IMG SRC="minus.gif" CLASS="coll" ONCLICK="toggle(this,'i:Nat')" ALT="show/hide"
> Instances</TD
></TR
><TR
><TD CLASS="body"
><DIV ID="i:Nat" STYLE="display:block;"
><TABLE CLASS="vanilla" CELLSPACING="1" CELLPADDING="0"
><TR
><TD CLASS="decl"
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/QuickCheck-1.1.0.0/Test-QuickCheck.html#t%3AArbitrary"
>Arbitrary</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Prelude.html#t%3AEnum"
>Enum</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Eq.html#t%3AEq"
>Eq</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Prelude.html#t%3AIntegral"
>Integral</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Prelude.html#t%3ANum"
>Num</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Ord.html#t%3AOrd"
>Ord</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Prelude.html#t%3AReal"
>Real</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Text-Show.html#t%3AShow"
>Show</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
><TR
><TD CLASS="decl"
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Typeable.html#t%3ATypeable"
>Typeable</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v%3AisSucc"
></A
><B
>isSucc</B
> :: <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
> -&gt; <A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Bool.html#t%3ABool"
>Bool</A
></TD
></TR
><TR
><TD CLASS="doc"
><TT
><TT
><A HREF="Test-ChasingBottoms-Nat.html#v%3AisSucc"
>isSucc</A
></TT
> 0 == <TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Bool.html#v%3AFalse"
>False</A
></TT
></TT
>, for other total natural numbers it is <TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Bool.html#v%3ATrue"
>True</A
></TT
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v%3AfromSucc"
></A
><B
>fromSucc</B
> :: <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
> -&gt; <A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Maybe.html#t%3AMaybe"
>Maybe</A
> <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
></TD
></TR
><TR
><TD CLASS="doc"
><TT
><TT
><A HREF="Test-ChasingBottoms-Nat.html#v%3AfromSucc"
>fromSucc</A
></TT
> 0 == <TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Maybe.html#v%3ANothing"
>Nothing</A
></TT
></TT
>, <TT
><TT
><A HREF="Test-ChasingBottoms-Nat.html#v%3AfromSucc"
>fromSucc</A
></TT
> (n+1) == <TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Maybe.html#v%3AJust"
>Just</A
></TT
> n</TT
> for a
 total natural number <TT
>n</TT
>.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v%3Anatrec"
></A
><B
>natrec</B
> :: a -&gt; (<A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
> -&gt; a -&gt; a) -&gt; <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="doc"
><TT
><A HREF="Test-ChasingBottoms-Nat.html#v%3Anatrec"
>natrec</A
></TT
> performs primitive recursion on natural numbers.
</TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="decl"
><A NAME="v%3AfoldN"
></A
><B
>foldN</B
> :: a -&gt; (a -&gt; a) -&gt; <A HREF="Test-ChasingBottoms-Nat.html#t%3ANat"
>Nat</A
> -&gt; a</TD
></TR
><TR
><TD CLASS="doc"
><P
><TT
><A HREF="Test-ChasingBottoms-Nat.html#v%3AfoldN"
>foldN</A
></TT
> is a fold on natural numbers:
</P
><PRE
>
  <TT
><A HREF="Test-ChasingBottoms-Nat.html#v%3AfoldN"
>foldN</A
></TT
> g h = <TT
><A HREF="Test-ChasingBottoms-Nat.html#v%3Anatrec"
>natrec</A
></TT
> g (<TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Tuple.html#v%3Acurry"
>curry</A
></TT
> <TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Prelude.html#v%3A%24"
>$</A
></TT
> h . <TT
><A HREF="http://www.haskell.org/ghc/docs/latest/html/libraries/base-3.0.0.0/Data-Tuple.html#v%3Asnd"
>snd</A
></TT
>)
 </PRE
></TD
></TR
><TR
><TD CLASS="s15"
></TD
></TR
><TR
><TD CLASS="botbar"
>Produced by <A HREF="http://www.haskell.org/haddock/"
>Haddock</A
> version 0.7</TD
></TR
></TABLE
></BODY
></HTML
>