lambdabot-4.0: scripts/hoogle/wiki/Keywords.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Keywords - The Haskell Wiki</title>
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="all" href="/moinwiki/classic/css/common.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="screen" href="/moinwiki/classic/css/screen.css">
<link rel="stylesheet" type="text/css" charset="iso-8859-1" media="print" href="/moinwiki/classic/css/print.css">
<link rel="Start" href="/hawiki/FrontPage">
<link rel="Alternate" title="Wiki Markup" href="/hawiki/Keywords?action=raw">
<link rel="Alternate" media="print" title="Print View" href="/hawiki/Keywords?action=print">
<link rel="Search" href="/hawiki/FindPage">
<link rel="Index" href="/hawiki/TitleIndex">
<link rel="Glossary" href="/hawiki/WordIndex">
<link rel="Help" href="/hawiki/HelpOnFormatting">
</head>
<body lang="en" dir="ltr">
<div id="logo"><a href="/hawiki/FrontPage"><img src="/small-lambda.gif" alt="The Haskell Wiki"></a></div>
<div id="username"><a href="/hawiki/UserPreferences">UserPreferences</a></div>
<div id="title"><h1><a title="Click here to do a full-text search for this title" href="/hawiki/Keywords?action=fullsearch&value=Keywords&literal=1&case=1&context=40">Keywords</a></h1></div>
<ul id="iconbar">
<li><a title="Edit" href="/hawiki/Keywords?action=edit"><img src="/moinwiki/classic/img/moin-edit.png" alt="Edit" height="12" width="12"></a></li>
<li><a title="View" href="/hawiki/Keywords"><img src="/moinwiki/classic/img/moin-show.png" alt="View" height="13" width="12"></a></li>
<li><a title="Diffs" href="/hawiki/Keywords?action=diff"><img src="/moinwiki/classic/img/moin-diff.png" alt="Diffs" height="11" width="15"></a></li>
<li><a title="Info" href="/hawiki/Keywords?action=info"><img src="/moinwiki/classic/img/moin-info.png" alt="Info" height="11" width="12"></a></li>
<li><a title="Subscribe" href="/hawiki/Keywords?action=subscribe"><img src="/moinwiki/classic/img/moin-subscribe.png" alt="Subscribe" height="10" width="14"></a></li>
<li><a title="Raw" href="/hawiki/Keywords?action=raw"><img src="/moinwiki/classic/img/moin-raw.png" alt="Raw" height="13" width="12"></a></li>
<li><a title="Print" href="/hawiki/Keywords?action=print"><img src="/moinwiki/classic/img/moin-print.png" alt="Print" height="14" width="16"></a></li>
</ul>
<ul id="navibar">
<li><a href="/hawiki/FrontPage">FrontPage</a></li>
<li><a href="/hawiki/RecentChanges">RecentChanges</a></li>
<li><a href="/hawiki/FindPage">FindPage</a></li>
<li><a href="/hawiki/HelpContents">HelpContents</a></li>
</ul>
<hr id="pagetrail">
<div id="content" lang="en" dir="ltr">
<h2 id="head-001691719917019301458dbe1a704b40e47d4593">Haskell Keywords</h2>
<p>
This page lists all Haskell keywords, feel free to edit. <a href="/hawiki/Hoogle">Hoogle</a> searches return results from this page. Please respect the Anchor macros.
</p>
<p>
Some of the material below is taken from <a class="external" href="http://www.haskell.org/onlinereport/"><img src="/moinwiki/classic/img/moin-www.png" alt="[WWW]" height="11" width="11">the Haskell 98 report</a>.
</p>
<p>
<a id="|"> <h3 id="head-3eb416223e9e69e6bb8ee19793911ad1ad2027d8">|</h3>
</p>
<pre class=code>
safeTail x | null x = []
| otherwise = tail x
squares = [a*a | a <- [1..]]
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
<a id="->"> <h3 id="head-6b8bdd37d6a5fe9bfd9ce2c3b38104fb717f3f22">-></h3>
</p>
<p>
Please write this
</p>
<p>
<a id="<-"> <h3 id="head-a9e43da8dc6372dda92a4ab32f4ddd6b09fe7660"><-</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="@"> <h3 id="head-9a78211436f6d425ec38f5c4e02270801f3524f8">@</h3>
</p>
<p>
Patterns of the form var@pat are called as-patterns, and allow one to use var as a name for the value being matched by pat. For example:
</p>
<pre class=code>
<B><FONT COLOR="#A020F0">case</FONT></B> e <B><FONT COLOR="#A020F0">of</FONT></B> { xs@(x:rest) -> <B><FONT COLOR="#A020F0">if</FONT></B> x==0 <B><FONT COLOR="#A020F0">then</FONT></B> rest <B><FONT COLOR="#A020F0">else</FONT></B> xs }
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
is equivalent to:
</p>
<pre class=code>
<B><FONT COLOR="#A020F0">let</FONT></B> { xs = e } <B><FONT COLOR="#A020F0">in</FONT></B>
<B><FONT COLOR="#A020F0">case</FONT></B> xs <B><FONT COLOR="#A020F0">of</FONT></B> { (x:rest) -> <B><FONT COLOR="#A020F0">if</FONT></B> x==0 <B><FONT COLOR="#A020F0">then</FONT></B> rest <B><FONT COLOR="#A020F0">else</FONT></B> xs }
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
<a id="!"> <h3 id="head-0ab8318acaf6e678dd02e2b5c343ed41111b393d">!</h3>
</p>
<p>
Whenever a data constructor is applied, each argument to the constructor is evaluated if and only if the corresponding type in the algebraic datatype declaration has a strictness flag, denoted by an exclamation point. For example:
</p>
<pre class=code>
<B><FONT COLOR="#A020F0">data</FONT></B> STList a
= STCons a !(STList a) <I><FONT COLOR="#B22222">-- the second argument to STCons will be
</FONT></I> <I><FONT COLOR="#B22222">-- evaluated before STCons is applied
</FONT></I> | STNil
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
to illustrate the difference between strict versus lazy constructor application, consider the following:
</p>
<pre class=code>
stList = STCons 1 undefined
lzList = (:) 1 undefined
stHead (STCons h <B><FONT COLOR="#A020F0">_) </FONT></B>= h <I><FONT COLOR="#B22222">-- this evaluates to undefined when applied to stList
</FONT></I>lzHead (h : <B><FONT COLOR="#A020F0">_) </FONT></B> = h <I><FONT COLOR="#B22222">-- this evaluates to 1 when applied to lzList
</FONT></I></PRE>
</BODY>
</HTML>
<p>
</p>
<p>
<a id="::"> <h3 id="head-f62e0ea6edbc4288ff84c8da24f410ecf986229d">::</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="_"> <h3 id="head-53a0acfad59379b3e050338bf9f23cfc172ee787">_</h3>
</p>
<p>
Patterns of the form _ are wildcards and are useful when some part of a pattern is not referenced on the right-hand-side. It is as if an identifier not used elsewhere were put in its place. For example,
</p>
<pre class=code>
<B><FONT COLOR="#A020F0">case</FONT></B> e <B><FONT COLOR="#A020F0">of</FONT></B> { [x,<B><FONT COLOR="#A020F0">_,_</FONT></B>] -> <B><FONT COLOR="#A020F0">if</FONT></B> x==0 <B><FONT COLOR="#A020F0">then</FONT></B> True <B><FONT COLOR="#A020F0">else</FONT></B> False }
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
is equivalent to:
</p>
<pre class=code>
<B><FONT COLOR="#A020F0">case</FONT></B> e <B><FONT COLOR="#A020F0">of</FONT></B> { [x,y,z] -> <B><FONT COLOR="#A020F0">if</FONT></B> x==0 <B><FONT COLOR="#A020F0">then</FONT></B> True <B><FONT COLOR="#A020F0">else</FONT></B> False }
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
<a id="~"> <h3 id="head-fb3c6e4de85bd9eae26fdc63e75f10a7f39e850e">~</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="as"> <h3 id="head-df211ccdd94a63e0bcb9e6ae427a249484a49d60">as</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="case"><a id="of"> <h3 id="head-48de8067d0428b7f3685d1f4651640bd1f4cf67a">case, of</h3>
</p>
<p>
A case expression has the general form
</p>
<pre class=code>
<B><FONT COLOR="#A020F0">case</FONT></B> e <B><FONT COLOR="#A020F0">of</FONT></B> { p1 match1 ; ... ; pn matchn }
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
where each match is of the general form
</p>
<pre class=code>
| g1 -> e1
...
| gm -> em
<B><FONT COLOR="#A020F0">where</FONT></B> decls
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
Each alternative consists of a pattern pi and its matches, matchi. Each match in turn consists of a sequence of pairs of guards gj and bodies ej (expressions), followed by optional bindings (decls) that scope over all of the guards and expressions of the alternative. An alternative of the form
</p>
<pre class=code>
pat -> exp <B><FONT COLOR="#A020F0">where</FONT></B> decls
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
is treated as shorthand for:
</p>
<pre class=code>
pat | True -> exp
<B><FONT COLOR="#A020F0">where</FONT></B> decls
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
A case expression must have at least one alternative and each alternative must have at least one body. Each body must have the same type, and the type of the whole expression is that type.
</p>
<p>
A case expression is evaluated by pattern matching the expression e against the individual alternatives. The alternatives are tried sequentially, from top to bottom. If e matches the pattern in the alternative, the guards for that alternative are tried sequentially from top to bottom, in the environment of the case expression extended first by the bindings created during the matching of the pattern, and then by the declsi in the where clause associated with that alternative. If one of the guards evaluates to True, the corresponding right-hand side is evaluated in the same environment as the guard. If all the guards evaluate to False, matching continues with the next alternative. If no match succeeds, the result is _|_.
</p>
<p>
<a id="class"> <h3 id="head-8d767bf5b72373d12f0efd4406677e9ed076f592">class</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="data"> <h3 id="head-a17c9aaa61e80a1bf71d0d850af4e5baa9800bbd">data</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="default"> <h3 id="head-7505d64a54e061b7acd54ccd58b49dc43500b635">default</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="deriving"> <h3 id="head-3c79f6126d9c3fb6932b3a13339d092090c2b4c0">deriving</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="do"> <h3 id="head-eadcd9bd2a09c75aef04954e6799e50278ee124a">do</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="forall"> <h3 id="head-7a5d1bfdef16352ea0c0772633abee7cfc8b3a3a">forall</h3>
</p>
<p>
This is a GHC/Hugs extension, and as such is not portable Haskell 98.
</p>
<p>
<a id="hiding"> <h3 id="head-0e8153596b53a6802e2d8265e43239963884cf13">hiding</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="if"><a id="then"><a id="else"> <h3 id="head-c5bdb5b7bd1da145ee2576114277e4d5b16d121d">if, then, else</h3>
</p>
<p>
A conditional expression has the form:
</p>
<pre class=code>
<B><FONT COLOR="#A020F0">if</FONT></B> e1 <B><FONT COLOR="#A020F0">then</FONT></B> e2 <B><FONT COLOR="#A020F0">else</FONT></B> e3
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
...and returns the value of e2 if the value of e1 is True, e3 if e1 is False, and _|_ otherwise.
</p>
<pre class=code>
max a b = <B><FONT COLOR="#A020F0">if</FONT></B> a > b <B><FONT COLOR="#A020F0">then</FONT></B> a <B><FONT COLOR="#A020F0">else</FONT></B> b
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
<a id="import"> <h3 id="head-62fdfbd55d19b2a4671102ad7bca17d875f8207a">import</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="infix"><a id="infixr"><a id="infixl"> <h3 id="head-538434472b62110fb7c204716d21e4ccfb40305d">infix, infixl, infixr</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="instance"> <h3 id="head-c3bec6bcbc9b9f04e60fcb1d9c9c1a37f3e12e93">instance</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="let"><a id="in"> <h3 id="head-89c4d2efdccc7367e3ac101d6e4db4eead4fcdda">let, in</h3>
</p>
<p>
Let expressions have the general form:
</p>
<pre class=code>
<B><FONT COLOR="#A020F0">let</FONT></B> { d1 ; ... ; dn } <B><FONT COLOR="#A020F0">in</FONT></B> e
</PRE>
</BODY>
</HTML>
<p>
</p>
<p>
They introduce a nested, lexically-scoped, mutually-recursive list of declarations (let is often called letrec in other languages). The scope of the declarations is the expression e and the right hand side of the declarations.
</p>
<p>
<a id="module"> <h3 id="head-fbd34a2b6e6a9fe8161f97dc435642609ac0bc29">module</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="newtype"> <h3 id="head-a4f7ecca3de79d65ba5665d08864fcc66bd20611">newtype</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="qualified"> <h3 id="head-9f04d6a7d7bb81380c6230d828b6b0454dab10aa">qualified</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="type"> <h3 id="head-d0a3e7f81a9885e99049d1cae0336d269d5e47a9">type</h3>
</p>
<p>
Please write this
</p>
<p>
<a id="where"> <h3 id="head-46148cc3b4d2b3ac8073f14b0cba7f25ffff54bd">where</h3>
</p>
<p>
Please write this
</p>
</div>
<div id="footer">
<div id="credits">
<p>
<a href="http://moinmoin.wikiwikiweb.de/">MoinMoin Powered</a><br>
<a href="http://www.python.org/">
<img src="/moinwiki/classic/img/PythonPowered.png" width="55" height="22" alt="PythonPowered">
</a>
</p>
</div>
<a href="/hawiki/Keywords?action=refresh&arena=Page.py&key=Keywords.text_html">RefreshCache</a> for this page (cached 2005-12-12 14:33:44)<br>
<p>Immutable page (last edited 2005-11-21 23:02:42 by <span title="midd-cache-5.server.ntli.net">MikeDodds</span>)</p>
<form method="POST" action="/hawiki/Keywords">
<p>
<input type="hidden" name="action" value="inlinesearch">
<input type="hidden" name="context" value="40">
<a href="/hawiki/FindPage?value=Keywords">FindPage</a> or search titles <input type="text" name="text_title" value="" size="15" maxlength="50"><input type="image" src="/moinwiki/classic/img/moin-search.png" name="button_title" alt="[?]">, full text <input type="text" name="text_full" value="" size="15" maxlength="50"><input type="image" src="/moinwiki/classic/img/moin-search.png" name="button_full" alt="[?]"> or <a href="/hawiki/SiteNavigation">SiteNavigation</a>
</p>
</form>
<p>Or try one of these actions: <a href="/hawiki/Keywords?action=DeletePage">DeletePage</a>, <a href="/hawiki/Keywords?action=LikePages">LikePages</a>, <a href="/hawiki/Keywords?action=LocalSiteMap">LocalSiteMap</a>, <a href="/hawiki/Keywords?action=SpellCheck">SpellCheck</a></p>
</div>
</body>
</html>