<!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" xml:lang="en" lang="en" dir="ltr">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
				<meta name="keywords" content="Keywords,Abstract syntax tree,Arrow notation,Constructor,Cunning Newtype Deriving,Foreign Function Interface,Functional dependencies,GADT,Hoogle,Implicit parameters,Import" />
		<link rel="shortcut icon" href="/favicon.ico" />
		<link rel="search" type="application/opensearchdescription+xml" href="/haskellwiki/opensearch_desc.php" title="HaskellWiki (English)" />
		<link title="Creative Commons" type="application/rdf+xml" href="/haskellwiki/index.php?title=Keywords&amp;action=creativecommons" rel="meta" />
		<link rel="copyright" href="/haskellwiki/HaskellWiki:Copyrights" />
<link rel="alternate" type="application/rss+xml" title="HaskellWiki RSS Feed" href="http://www.haskell.org/haskellwiki/index.php?title=Special:Recentchanges&amp;feed=rss" />
<link rel="alternate" type="application/atom+xml" title="HaskellWiki Atom Feed" href="http://www.haskell.org/haskellwiki/index.php?title=Special:Recentchanges&amp;feed=atom" />
		<title>Keywords - HaskellWiki</title>
		<style type="text/css" media="screen, projection">/*<![CDATA[*/
			@import "/wikistatic/skins//common/shared.css?116";
			@import "/wikistatic/skins//hawiki/main.css?116";
		/*]]>*/</style>
		<link rel="stylesheet" type="text/css" media="print" href="/wikistatic/skins//common/commonPrint.css?116" />
		<!--[if lt IE 5.5000]><style type="text/css">@import "/wikistatic/skins//hawiki/IE50Fixes.css?116";</style><![endif]-->
		<!--[if IE 5.5000]><style type="text/css">@import "/wikistatic/skins//hawiki/IE55Fixes.css?116";</style><![endif]-->
		<!--[if IE 6]><style type="text/css">@import "/wikistatic/skins//hawiki/IE60Fixes.css?116";</style><![endif]-->
		<!--[if IE 7]><style type="text/css">@import "/wikistatic/skins//hawiki/IE70Fixes.css?116";</style><![endif]-->
		<!--[if lte IE 7]><script type="text/javascript" src="/wikistatic/skins//hawiki/IEFixes.js?116"></script>
		<meta http-equiv="imagetoolbar" content="no" /><![endif]-->
                                                <script type="text/javascript">
                        var isMSIE55 = (window.showModalDialog && window.clipboardData && window.createPopup); /*alert("test: " + isMSIE55);*/</script>

		<script type= "text/javascript">/*<![CDATA[*/
var skin = "hawiki";
var stylepath = "/wikistatic/skins/";
var wgArticlePath = "/haskellwiki/$1";
var wgScriptPath = "/haskellwiki";
var wgScript = "/haskellwiki/index.php";
var wgServer = "http://www.haskell.org";
var wgCanonicalNamespace = "";
var wgCanonicalSpecialPageName = false;
var wgNamespaceNumber = 0;
var wgPageName = "Keywords";
var wgTitle = "Keywords";
var wgAction = "view";
var wgRestrictionEdit = [];
var wgRestrictionMove = [];
var wgArticleId = "1373";
var wgIsArticle = true;
var wgUserName = null;
var wgUserGroups = null;
var wgUserLanguage = "en";
var wgContentLanguage = "en";
var wgBreakFrames = false;
var wgCurRevisionId = "47894";
var wgVersion = "1.12.0";
var wgEnableAPI = true;
var wgEnableWriteAPI = false;
/*]]>*/</script>

		<script type="text/javascript" src="/wikistatic/skins//common/wikibits.js?116"><!-- wikibits js --></script>
		<!-- Head Scripts -->
		<script type="text/javascript" src="/wikistatic/skins//common/ajax.js?116"></script>
<style type="text/css">/*<![CDATA[*/
.source-haskell {line-height: normal;}
.source-haskell li {line-height: normal;}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for haskell
 * CSS class: source-haskell, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.source-haskell .de1, .source-haskell .de2 {font-family: 'Courier New', Courier, monospace; font-weight: normal; font-style: normal;}
.source-haskell  {}
.source-haskell .head {}
.source-haskell .foot {}
.source-haskell .imp {font-weight: bold; color: red;}
.source-haskell li, .source-haskell li.li1 {font-weight: normal;}
.source-haskell li.li2 {font-weight: bold;}
.source-haskell .kw1 {color: #06c; font-weight: bold;}
.source-haskell .kw2 {color: #06c; font-weight: bold;}
.source-haskell .kw3 {font-weight: bold;}
.source-haskell .kw4 {color: #cccc00; font-weight: bold;}
.source-haskell .kw5 {color: maroon;}
.source-haskell .co1 {color: #5d478b; font-style: italic;}
.source-haskell .co2 {color: #339933; font-weight: bold;}
.source-haskell .coMULTI {color: #5d478b; font-style: italic;}
.source-haskell .es0 {background-color: #3cb371; font-weight: bold;}
.source-haskell .br0 {color: green;}
.source-haskell .sy0 {color: #339933; font-weight: bold;}
.source-haskell .st0 {background-color: #3cb371;}
.source-haskell .nu0 {color: red;}
.source-haskell .me1 {color: #060;}
.source-haskell .ln-xtra, .source-haskell li.ln-xtra, .source-haskell div.ln-xtra {color: #cc0; background-color: #ffc;}

/*]]>*/
</style>
<style type="text/css">/*<![CDATA[*/
@import "/haskellwiki/index.php?title=MediaWiki:Geshi.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
/*]]>*/
</style>		<script type="text/javascript" src="/haskellwiki/index.php?title=-&amp;action=raw&amp;gen=js&amp;useskin=hawiki"><!-- site js --></script>
		<style type="text/css">/*<![CDATA[*/
@import "/haskellwiki/index.php?title=MediaWiki:Common.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
@import "/haskellwiki/index.php?title=MediaWiki:Hawiki.css&usemsgcache=yes&action=raw&ctype=text/css&smaxage=18000";
@import "/haskellwiki/index.php?title=-&action=raw&gen=css&maxage=18000&useskin=hawiki";
/*]]>*/</style>
	</head>
<body class="mediawiki ltr page-Keywords ">
   <div id="topbar" class="noprint">
	<div class="portlet noprint" id="p-personal">
		<h5>Personal tools</h5>
		<div class="pBody">
			<ul><li><a class="homebutton" href="/haskellwiki/Haskell">Home</a></li>
				<li id="pt-login"><a href="/haskellwiki/index.php?title=Special:Userlogin&amp;returnto=Keywords" title="You are encouraged to log in, it is not mandatory however. [o]" accesskey="o">Log in / create account</a></li>
			</ul>
		</div>
	</div>
        	  <div id="p-search">
	    <div id="searchBody" class="pBody">
	       <form action="/haskellwiki/index.php" id="searchform"><div>
	          <input type='hidden' name="title" value=""/>
	          <input id="searchInput" name="search" type="text" title="Search HaskellWiki [f]" accesskey="f" value="" />
				<input type='submit' name="go" class="searchButton" id="searchGoButton"	value="Go" title="Go to a page with this exact name if exists" />&nbsp;
				<input type='submit' name="fulltext" class="searchButton" id="mw-searchButton" value="Search" title="Search the pages for this text" />

	         </div></form>
	    </div>
	  </div>
   </div>
	<div id="globalWrapper">
	<div class="portlet" id="p-logo">
		<a style="background-image: url(/wikistatic/haskellwiki_logo.png);" href="/haskellwiki/Haskell" title="Main Page"></a>
	</div>
	<div id="column-content">
        <div id="notice-area" class="noprint">
        <!-- ?php $this->data['sitenotice'] = 'This is a test instance.  Do not edit, your changes will be lost.'; ? -->
			        </div>
        <div id="content-wrapper">
	<div id="p-cactions" class="portlet noprint">
		<h5>Views</h5>
		<div class="pBody">
			<ul>
	
				 <li id="ca-nstab-main" class="selected"><a href="/haskellwiki/Keywords" title="View the content page [c]" accesskey="c">Page</a></li>
				 <li id="ca-talk" class="new"><a href="/haskellwiki/index.php?title=Talk:Keywords&amp;action=edit" title="Discussion about the content page [t]" accesskey="t">Discussion</a></li>
				 <li id="ca-viewsource"><a href="/haskellwiki/index.php?title=Keywords&amp;action=edit" title="This page is protected. You can view its source. [e]" accesskey="e">View source</a></li>
				 <li id="ca-history"><a href="/haskellwiki/index.php?title=Keywords&amp;action=history" title="Past versions of this page. [h]" accesskey="h">History</a></li>			</ul>
		</div>
	</div>
                        <div id="content">
		<a name="top" id="top"></a>
                        <h1 id="firstHeading" class="firstHeading">Keywords</h1>
		<div id="bodyContent">
			<h3 id="siteSub">From HaskellWiki</h3>
			<div id="contentSub"></div>
			<div id="jump-to-nav">Jump to: <a href="#column-one">navigation</a>, <a href="#searchInput">search</a></div>			<!-- start content -->
			<p>This page lists all Haskell keywords, feel free to edit. <a href="/haskellwiki/Hoogle" title="Hoogle">Hoogle</a> searches will return results from this page. Please respect the Anchor macros.
</p><p>For additional information you might want to look at <a href="http://www.haskell.org/onlinereport/" class="external text" title="http://www.haskell.org/onlinereport/" rel="nofollow">the Haskell 98 report</a>.
</p>
<table id="toc" class="toc" summary="Contents"><tr><td><div id="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1"><a href="#.21"><span class="tocnumber">1</span> <span class="toctext">!</span></a></li>
<li class="toclevel-1"><a href="#.27"><span class="tocnumber">2</span> <span class="toctext">'</span></a></li>
<li class="toclevel-1"><a href="#.27.27"><span class="tocnumber">3</span> <span class="toctext">''</span></a></li>
<li class="toclevel-1"><a href="#-"><span class="tocnumber">4</span> <span class="toctext">-</span></a></li>
<li class="toclevel-1"><a href="#--"><span class="tocnumber">5</span> <span class="toctext">--</span></a></li>
<li class="toclevel-1"><a href="#-.3C"><span class="tocnumber">6</span> <span class="toctext">-&lt;</span></a></li>
<li class="toclevel-1"><a href="#-.3C.3C"><span class="tocnumber">7</span> <span class="toctext">-&lt;&lt;</span></a></li>
<li class="toclevel-1"><a href="#-.3E"><span class="tocnumber">8</span> <span class="toctext">-&gt;</span></a></li>
<li class="toclevel-1"><a href="#::"><span class="tocnumber">9</span> <span class="toctext">::</span></a></li>
<li class="toclevel-1"><a href="#.3B"><span class="tocnumber">10</span> <span class="toctext">;</span></a></li>
<li class="toclevel-1"><a href="#.3C-"><span class="tocnumber">11</span> <span class="toctext">&lt;-</span></a></li>
<li class="toclevel-1"><a href="#.3D"><span class="tocnumber">12</span> <span class="toctext">=</span></a></li>
<li class="toclevel-1"><a href="#.3D.3E"><span class="tocnumber">13</span> <span class="toctext">=&gt;</span></a></li>
<li class="toclevel-1"><a href="#.3E"><span class="tocnumber">14</span> <span class="toctext">&gt;</span></a></li>
<li class="toclevel-1"><a href="#.3F"><span class="tocnumber">15</span> <span class="toctext">?</span></a></li>
<li class="toclevel-1"><a href="#.3F.3F"><span class="tocnumber">16</span> <span class="toctext">??</span></a></li>
<li class="toclevel-1"><a href="#.23"><span class="tocnumber">17</span> <span class="toctext">#</span></a></li>
<li class="toclevel-1"><a href="#.28.23.29"><span class="tocnumber">18</span> <span class="toctext">(#)</span></a></li>
<li class="toclevel-1"><a href="#.2A"><span class="tocnumber">19</span> <span class="toctext">*</span></a></li>
<li class="toclevel-1"><a href="#.40"><span class="tocnumber">20</span> <span class="toctext">@</span></a></li>
<li class="toclevel-1"><a href="#.5B.7C.2C_.7C.5D"><span class="tocnumber">21</span> <span class="toctext">[|, |]</span></a></li>
<li class="toclevel-1"><a href="#.5C"><span class="tocnumber">22</span> <span class="toctext">\</span></a></li>
<li class="toclevel-1"><a href="#_"><span class="tocnumber">23</span> <span class="toctext">_</span></a></li>
<li class="toclevel-1"><a href="#.60"><span class="tocnumber">24</span> <span class="toctext">`</span></a></li>
<li class="toclevel-1"><a href="#.7B.2C_.7D"><span class="tocnumber">25</span> <span class="toctext">{, }</span></a></li>
<li class="toclevel-1"><a href="#.7B-.2C_-.7D"><span class="tocnumber">26</span> <span class="toctext">{-, -}</span></a></li>
<li class="toclevel-1"><a href="#.7C"><span class="tocnumber">27</span> <span class="toctext">|</span></a></li>
<li class="toclevel-1"><a href="#.7E"><span class="tocnumber">28</span> <span class="toctext">~</span></a></li>
<li class="toclevel-1"><a href="#as"><span class="tocnumber">29</span> <span class="toctext">as</span></a></li>
<li class="toclevel-1"><a href="#case.2C_of"><span class="tocnumber">30</span> <span class="toctext">case, of</span></a></li>
<li class="toclevel-1"><a href="#class"><span class="tocnumber">31</span> <span class="toctext">class</span></a></li>
<li class="toclevel-1"><a href="#data"><span class="tocnumber">32</span> <span class="toctext">data</span></a></li>
<li class="toclevel-1"><a href="#data_family"><span class="tocnumber">33</span> <span class="toctext">data family</span></a></li>
<li class="toclevel-1"><a href="#data_instance"><span class="tocnumber">34</span> <span class="toctext">data instance</span></a></li>
<li class="toclevel-1"><a href="#default"><span class="tocnumber">35</span> <span class="toctext">default</span></a></li>
<li class="toclevel-1"><a href="#deriving"><span class="tocnumber">36</span> <span class="toctext">deriving</span></a></li>
<li class="toclevel-1"><a href="#deriving_instance"><span class="tocnumber">37</span> <span class="toctext">deriving instance</span></a></li>
<li class="toclevel-1"><a href="#do"><span class="tocnumber">38</span> <span class="toctext">do</span></a></li>
<li class="toclevel-1"><a href="#forall"><span class="tocnumber">39</span> <span class="toctext">forall</span></a></li>
<li class="toclevel-1"><a href="#foreign"><span class="tocnumber">40</span> <span class="toctext">foreign</span></a></li>
<li class="toclevel-1"><a href="#hiding"><span class="tocnumber">41</span> <span class="toctext">hiding</span></a></li>
<li class="toclevel-1"><a href="#if.2C_then.2C_else"><span class="tocnumber">42</span> <span class="toctext">if, then, else</span></a></li>
<li class="toclevel-1"><a href="#import"><span class="tocnumber">43</span> <span class="toctext">import</span></a></li>
<li class="toclevel-1"><a href="#infix.2C_infixl.2C_infixr"><span class="tocnumber">44</span> <span class="toctext">infix, infixl, infixr</span></a></li>
<li class="toclevel-1"><a href="#instance"><span class="tocnumber">45</span> <span class="toctext">instance</span></a></li>
<li class="toclevel-1"><a href="#let.2C_in"><span class="tocnumber">46</span> <span class="toctext">let, in</span></a></li>
<li class="toclevel-1"><a href="#mdo"><span class="tocnumber">47</span> <span class="toctext">mdo</span></a></li>
<li class="toclevel-1"><a href="#module"><span class="tocnumber">48</span> <span class="toctext">module</span></a></li>
<li class="toclevel-1"><a href="#newtype"><span class="tocnumber">49</span> <span class="toctext">newtype</span></a></li>
<li class="toclevel-1"><a href="#proc"><span class="tocnumber">50</span> <span class="toctext">proc</span></a></li>
<li class="toclevel-1"><a href="#qualified"><span class="tocnumber">51</span> <span class="toctext">qualified</span></a></li>
<li class="toclevel-1"><a href="#rec"><span class="tocnumber">52</span> <span class="toctext">rec</span></a></li>
<li class="toclevel-1"><a href="#type"><span class="tocnumber">53</span> <span class="toctext">type</span></a></li>
<li class="toclevel-1"><a href="#type_family"><span class="tocnumber">54</span> <span class="toctext">type family</span></a></li>
<li class="toclevel-1"><a href="#type_instance"><span class="tocnumber">55</span> <span class="toctext">type instance</span></a></li>
<li class="toclevel-1"><a href="#where"><span class="tocnumber">56</span> <span class="toctext">where</span></a></li>
</ul>
</td></tr></table><script type="text/javascript"> if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); } </script>
<a name=".21"></a><h2> <span class="mw-headline">1 &nbsp;! </span></h2>
<p>Whenever a data <a href="/haskellwiki/Constructor" title="Constructor">constructor</a> is applied, each argument to the
constructor is evaluated if and only if the corresponding type in the
algebraic data<a href="/haskellwiki/Type" title="Type">type</a> declaration has a strictness flag, denoted by an
exclamation point. For example:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">data</span> STList a 
         <span class="sy0">=</span> STCons a <span class="sy0">!</span><span class="br0">&#40;</span>STList a<span class="br0">&#41;</span>  <span class="co1">-- the second argument to STCons will be </span>
                                 <span class="co1">-- evaluated before STCons is applied</span>
         <span class="sy0">|</span> STNil</pre></div>
<p>to illustrate the difference between strict versus lazy constructor
application, consider the following:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">stList <span class="sy0">=</span> STCons <span class="nu0">1</span> <span class="kw3">undefined</span>
 lzList <span class="sy0">=</span> <span class="br0">&#40;</span>:<span class="br0">&#41;</span>    <span class="nu0">1</span> <span class="kw3">undefined</span>
 stHead <span class="br0">&#40;</span>STCons h <span class="sy0">_</span><span class="br0">&#41;</span> <span class="sy0">=</span> h <span class="co1">-- this evaluates to undefined when applied to stList</span>
 lzHead <span class="br0">&#40;</span>h&nbsp;: <span class="sy0">_</span><span class="br0">&#41;</span>      <span class="sy0">=</span> h <span class="co1">-- this evaluates to 1 when applied to lzList</span></pre></div>
<p>! is also used in the <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/bang-patterns.html" class="external text" title="http://www.haskell.org/ghc/docs/latest/html/users_guide/bang-patterns.html" rel="nofollow">"bang patterns"</a> (GHC extension), to indicate
strictness in patterns:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">f <span class="sy0">!</span>x <span class="sy0">!</span>y <span class="sy0">=</span> x <span class="sy0">+</span> y</pre></div>
<a name=".27"></a><h2> <span class="mw-headline">2  ' </span></h2>
<ul><li> Character literal: <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;">'a'</div></div></div>
</li><li> <a href="/haskellwiki/Template_Haskell" title="Template Haskell">Template Haskell</a>: Name of a (value) variable or data constructor: <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;">'<span class="kw3">length</span></div></div></div>, <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;">'Left</div></div></div>
</li></ul>
<a name=".27.27"></a><h2> <span class="mw-headline">3  '' </span></h2>
<ul><li> <a href="/haskellwiki/Template_Haskell" title="Template Haskell">Template Haskell</a>: Name of a type constructor or class: <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;">''<span class="kw4">Int</span></div></div></div>, <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;">''<span class="kw4">Either</span></div></div></div>, <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;">''<span class="kw4">Show</span></div></div></div>
</li></ul>
<a name="-"></a><h2> <span class="mw-headline">4  - </span></h2>
<p>This operator token is magic/irregular in the sense that
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="br0">&#40;</span><span class="sy0">-</span> <span class="nu0">1</span><span class="br0">&#41;</span></pre></div>
<p>is parsed as the negative integer -1, rather than as an operator <a href="/haskellwiki/index.php?title=Section&amp;action=edit" class="new" title="Section">section</a>, as it would be for any other operator:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="br0">&#40;</span><span class="sy0">*</span> <span class="nu0">1</span><span class="br0">&#41;</span> <span class="sy0">::</span> <span class="kw4">Num</span> a <span class="sy0">=&gt;</span> a <span class="sy0">-&gt;</span> a</pre></div>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="br0">&#40;</span><span class="sy0">++</span> <span class="st0">&quot;foo&quot;</span><span class="br0">&#41;</span> <span class="sy0">::</span> <span class="kw4">String</span> <span class="sy0">-&gt;</span> <span class="kw4">String</span></pre></div>
It is syntactic sugar for the <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw3">negate</span></div></div></div> function in Prelude. See <a href="/haskellwiki/Unary_operator" title="Unary operator">unary operator</a>.
If you want the section, you can use the <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw3">subtract</span></div></div></div> function or <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="br0">&#40;</span><span class="sy0">+</span><span class="br0">&#40;</span><span class="nu0">-1</span><span class="br0">&#41;</span><span class="br0">&#41;</span></div></div></div>.
<a name="--"></a><h2> <span class="mw-headline">5  -- </span></h2>
Starts a single-line comment, unless immediately followed by an operator character other than <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="sy0">-</span></div></div></div>:
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">main <span class="sy0">=</span> <span class="kw3">print</span> <span class="st0">&quot;hello world&quot;</span> <span class="co1">-- this is a comment</span>
<span class="co1">--this is a comment as well</span>
<span class="co1">---this too</span>
foobar <span class="sy0">-</span>​<span class="sy0">-+</span> this<span class="sy0">_</span>is<span class="sy0">_</span>the<span class="sy0">_</span>second<span class="sy0">_</span>argument<span class="sy0">_</span>of<span class="sy0">_</span>the<span class="sy0">_</span>dash<span class="sy0">_</span>dash<span class="sy0">_</span>plus<span class="sy0">_</span>operator</pre></div>
The multi-line variant for comments is <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="coMULTI">{- comment -}</span></div></div></div>.
<a name="-.3C"></a><h2> <span class="mw-headline">6  -&lt; </span></h2>
<p><a href="/haskellwiki/Arrow_notation" title="Arrow notation">Arrow notation</a>
</p>
<a name="-.3C.3C"></a><h2> <span class="mw-headline">7  -&lt;&lt; </span></h2>
<p><a href="/haskellwiki/Arrow_notation" title="Arrow notation">Arrow notation</a>
</p><p><br />
</p>
<a name="-.3E"></a><h2> <span class="mw-headline">8  -&gt; </span></h2>
<ul><li> The function type constructor:
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw3">length</span> <span class="sy0">::</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="kw4">Int</span></pre></div>
<ul><li> In lambda functions:
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">\x <span class="sy0">-&gt;</span> x <span class="sy0">+</span> <span class="nu0">1</span></pre></div>
<ul><li> To denote alternatives in case statements:
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">case</span> Just <span class="nu0">3</span> <span class="kw1">of</span>
    Nothing <span class="sy0">-&gt;</span> False
    Just x  <span class="sy0">-&gt;</span> True</pre></div>
<ul><li> On the kind level (GHC specific):
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">ghci<span class="sy0">&gt;</span>&nbsp;:kind <span class="br0">&#40;</span><span class="sy0">-&gt;</span><span class="br0">&#41;</span>
<span class="br0">&#40;</span><span class="sy0">-&gt;</span><span class="br0">&#41;</span> <span class="sy0">::</span> <span class="sy0">??</span> <span class="sy0">-&gt;</span> <span class="sy0">?</span> <span class="sy0">-&gt;</span> <span class="sy0">*</span></pre></div>
<ul><li> <a href="/haskellwiki/Functional_dependencies" class="mw-redirect" title="Functional dependencies">Functional dependencies</a>
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="co1">-- This examples assumes that each type 'c' can &quot;contain&quot; only one type</span>
<span class="co1">--  i.e. type 'c' uniquely determines type 'elt'</span>
<span class="kw1">class</span> Contains c elt <span class="sy0">|</span> c <span class="sy0">-&gt;</span> elt <span class="kw1">where</span>
   <span class="sy0">...</span></pre></div>
<ul><li> <a href="/haskellwiki/View_patterns" title="View patterns">View patterns</a>
</li></ul>
<a name="::"></a><h2> <span class="mw-headline">9 &nbsp;:: </span></h2>
<p>Read as "has type":
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw3">length</span> <span class="sy0">::</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="kw4">Int</span></pre></div>
<p>"Length has type list-of-'a' to Int"
</p><p>Or "has kind" (GHC specific):
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw4">Either</span> <span class="sy0">::</span> <span class="sy0">*</span> <span class="sy0">-&gt;</span> <span class="sy0">*</span> <span class="sy0">-&gt;</span> <span class="sy0">*</span></pre></div>
<a name=".3B"></a><h2> <span class="mw-headline">10 &nbsp;; </span></h2>
<ul><li> Statement separator in an explicit block (see <a href="/haskellwiki/Layout" title="Layout">layout</a>)
</li></ul>
<a name=".3C-"></a><h2> <span class="mw-headline">11  &lt;- </span></h2>
<ul><li> In do-notation, "draw from":
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">do</span> x <span class="sy0">&lt;-</span> <span class="kw3">getChar</span>
   <span class="kw3">putChar</span> x</pre></div>
<ul><li> In list comprehension generators, "is drawn from":
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="br0">&#91;</span> <span class="br0">&#40;</span>x<span class="sy0">,</span>y<span class="br0">&#41;</span> <span class="sy0">|</span> x <span class="sy0">&lt;-</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">..</span><span class="nu0">10</span><span class="br0">&#93;</span><span class="sy0">,</span> y <span class="sy0">&lt;-</span> <span class="br0">&#91;</span>'a'<span class="sy0">..</span>'z'<span class="br0">&#93;</span> <span class="br0">&#93;</span></pre></div>
<ul><li> In <a href="/haskellwiki/Pattern_guard" title="Pattern guard">pattern guards</a>, "matches":
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">f x y <span class="sy0">|</span> Just z <span class="sy0">&lt;-</span> g x <span class="sy0">=</span> True
      <span class="sy0">|</span> <span class="kw3">otherwise</span>     <span class="sy0">=</span> False</pre></div>
<a name=".3D"></a><h2> <span class="mw-headline">12  = </span></h2>
<p>Used in definitions.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">x <span class="sy0">=</span> <span class="nu0">4</span></pre></div>
<a name=".3D.3E"></a><h2> <span class="mw-headline">13  =&gt; </span></h2>
<p>Used to indicate instance contexts, for example:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">sort <span class="sy0">::</span> <span class="kw4">Ord</span> a <span class="sy0">=&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span></pre></div>
<a name=".3E"></a><h2> <span class="mw-headline">14  &gt; </span></h2>
<p>In a Bird's style <a href="/haskellwiki/Literate_programming" title="Literate programming">Literate Haskell file</a>, the &gt; character is used to introduce a code line.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">comment line
&nbsp;
<span class="sy0">&gt;</span> main <span class="sy0">=</span> <span class="kw3">print</span> <span class="st0">&quot;hello world&quot;</span></pre></div>
<a name=".3F"></a><h2> <span class="mw-headline">15 &nbsp;? </span></h2>
<ul><li> <a href="/haskellwiki/Implicit_parameters" title="Implicit parameters">Implicit parameters</a>
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">ghci<span class="sy0">&gt;</span>&nbsp;:t <span class="sy0">?</span>foo <span class="sy0">++</span> <span class="st0">&quot;bar&quot;</span>
<span class="sy0">?</span>foo <span class="sy0">++</span> <span class="st0">&quot;bar&quot;</span> <span class="sy0">::</span> <span class="br0">&#40;</span><span class="sy0">?</span>foo<span class="sy0">::</span><span class="br0">&#91;</span><span class="kw4">Char</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="sy0">=&gt;</span> <span class="br0">&#91;</span><span class="kw4">Char</span><span class="br0">&#93;</span></pre></div>
<ul><li> On the <a href="/haskellwiki/Kind" title="Kind">kind</a> level: The union of <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="sy0">??</span></div></div></div> and <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="br0">&#40;</span>#<span class="br0">&#41;</span></div></div></div>  (GHC-specific) 
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">ghci<span class="sy0">&gt;</span>&nbsp;:kind <span class="br0">&#40;</span><span class="sy0">-&gt;</span><span class="br0">&#41;</span>
<span class="br0">&#40;</span><span class="sy0">-&gt;</span><span class="br0">&#41;</span> <span class="sy0">::</span> <span class="sy0">??</span> <span class="sy0">-&gt;</span> <span class="sy0">?</span> <span class="sy0">-&gt;</span> <span class="sy0">*</span></pre></div>
<a name=".3F.3F"></a><h2> <span class="mw-headline">16 &nbsp;?? </span></h2>
<ul><li> Is an ordinary operator name on the value level and on the type level
</li></ul>
<ul><li> On the <a href="/haskellwiki/Kind" title="Kind">kind</a> level: The union of <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="sy0">*</span></div></div></div> and <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;">#</div></div></div> (GHC-specific) 
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">ghci<span class="sy0">&gt;</span>&nbsp;:kind <span class="br0">&#40;</span><span class="sy0">-&gt;</span><span class="br0">&#41;</span>
<span class="br0">&#40;</span><span class="sy0">-&gt;</span><span class="br0">&#41;</span> <span class="sy0">::</span> <span class="sy0">??</span> <span class="sy0">-&gt;</span> <span class="sy0">?</span> <span class="sy0">-&gt;</span> <span class="sy0">*</span></pre></div>
<a name=".23"></a><h2> <span class="mw-headline">17  # </span></h2>
<ul><li> <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#magic-hash" class="external text" title="http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#magic-hash" rel="nofollow">MagicHash</a>
</li></ul>
<ul><li> On the <a href="/haskellwiki/Kind" title="Kind">kind</a> level: The kind of <a href="/haskellwiki/Unboxed" class="mw-redirect" title="Unboxed">unboxed</a> types (GHC-specific) 
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">ghci<span class="sy0">&gt;</span>&nbsp;:m <span class="sy0">+</span>GHC<span class="sy0">.</span>Prim
ghci<span class="sy0">&gt;</span>&nbsp;:set <span class="sy0">-</span>XMagicHash
ghci<span class="sy0">&gt;</span>&nbsp;:kind <span class="kw4">Int</span>#
<span class="kw4">Int</span># <span class="sy0">::</span> #</pre></div>
<a name=".28.23.29"></a><h2> <span class="mw-headline">18  (#) </span></h2>
<ul><li> On the <a href="/haskellwiki/Kind" title="Kind">kind</a> level: The kind of <a href="/haskellwiki/Unboxed" class="mw-redirect" title="Unboxed">unboxed</a> tuples (GHC-specific) 
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">ghci<span class="sy0">&gt;</span>&nbsp;:set <span class="sy0">-</span>XMagicHash <span class="sy0">-</span>XUnboxedTuples
ghci<span class="sy0">&gt;</span> ghci<span class="sy0">&gt;</span>&nbsp;:k <span class="br0">&#40;</span># <span class="kw4">Char</span><span class="sy0">,</span><span class="kw4">Int</span> #<span class="br0">&#41;</span>
<span class="br0">&#40;</span># <span class="kw4">Char</span><span class="sy0">,</span><span class="kw4">Int</span> #<span class="br0">&#41;</span> <span class="sy0">::</span> <span class="br0">&#40;</span>#<span class="br0">&#41;</span></pre></div>
<a name=".2A"></a><h2> <span class="mw-headline">19  * </span></h2>
<ul><li> Is an ordinary operator name on the value level
</li></ul>
<ul><li> On the <a href="/haskellwiki/Kind" title="Kind">kind</a> level: The kind of boxed types (GHC-specific) 
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">ghci<span class="sy0">&gt;</span>&nbsp;:kind <span class="kw4">Int</span>
<span class="kw4">Int</span> <span class="sy0">::</span> <span class="sy0">*</span></pre></div>
<a name=".40"></a><h2> <span class="mw-headline">20  @ </span></h2>
<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>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">case</span> e <span class="kw1">of</span> <span class="br0">&#123;</span> xs<span class="sy0">@</span><span class="br0">&#40;</span>x:rest<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="kw1">if</span> x<span class="sy0">==</span><span class="nu0">0</span> <span class="kw1">then</span> rest <span class="kw1">else</span> xs <span class="br0">&#125;</span></pre></div>
<p>is equivalent to:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">let</span> <span class="br0">&#123;</span> xs <span class="sy0">=</span> e <span class="br0">&#125;</span> <span class="kw1">in</span>
   <span class="kw1">case</span> xs <span class="kw1">of</span> <span class="br0">&#123;</span> <span class="br0">&#40;</span>x:rest<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="kw1">if</span> x<span class="sy0">==</span><span class="nu0">0</span> <span class="kw1">then</span> rest <span class="kw1">else</span> xs <span class="br0">&#125;</span></pre></div>
<a name=".5B.7C.2C_.7C.5D"></a><h2> <span class="mw-headline">21  [|, |] </span></h2>
<ul><li> <a href="/haskellwiki/Template_Haskell" title="Template Haskell">Template Haskell</a>
<ul><li> Expression quotation: <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="br0">&#91;</span><span class="sy0">|</span> <span class="kw3">print</span> <span class="nu0">1</span> <span class="sy0">|</span><span class="br0">&#93;</span></div></div></div>
</li><li> Declaration quotation: <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="br0">&#91;</span>d<span class="sy0">|</span> main <span class="sy0">=</span> <span class="kw3">print</span> <span class="nu0">1</span> <span class="sy0">|</span><span class="br0">&#93;</span></div></div></div>
</li><li> Type quotation: <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="br0">&#91;</span>t<span class="sy0">|</span> <span class="kw4">Either</span> <span class="kw4">Int</span> <span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="sy0">|</span><span class="br0">&#93;</span></div></div></div> 
</li><li> Pattern quotation: <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="br0">&#91;</span>p<span class="sy0">|</span> <span class="br0">&#40;</span>x<span class="sy0">,</span>y<span class="br0">&#41;</span> <span class="sy0">|</span><span class="br0">&#93;</span></div></div></div>
</li><li> <a href="/haskellwiki/Quasiquotation" title="Quasiquotation">Quasiquotation</a>: <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="br0">&#91;</span>nameOfQuasiQuoter<span class="sy0">|</span> <span class="sy0">...</span> <span class="sy0">|</span><span class="br0">&#93;</span></div></div></div>
</li></ul>
</li></ul>
<a name=".5C"></a><h2> <span class="mw-headline">22  \ </span></h2>
<p>The backslash "\" is used
</p>
<ul><li> in multiline strings
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="st0">&quot;foo<span class="es0">\</span>
  <span class="es0">\b</span>ar&quot;</span></pre></div>
<ul><li> in lambda functions
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">\x <span class="sy0">-&gt;</span> x <span class="sy0">+</span> <span class="nu0">1</span></pre></div>
<p><br />
</p>
<a name="_"></a><h2> <span class="mw-headline">23  _ </span></h2>
<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>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">case</span> e <span class="kw1">of</span> <span class="br0">&#123;</span> <span class="br0">&#91;</span>x<span class="sy0">,_,_</span><span class="br0">&#93;</span>  <span class="sy0">-&gt;</span>  <span class="kw1">if</span> x<span class="sy0">==</span><span class="nu0">0</span> <span class="kw1">then</span> True <span class="kw1">else</span> False <span class="br0">&#125;</span></pre></div>
<p>is equivalent to:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">case</span> e <span class="kw1">of</span> <span class="br0">&#123;</span> <span class="br0">&#91;</span>x<span class="sy0">,</span>y<span class="sy0">,</span>z<span class="br0">&#93;</span>  <span class="sy0">-&gt;</span>  <span class="kw1">if</span> x<span class="sy0">==</span><span class="nu0">0</span> <span class="kw1">then</span> True <span class="kw1">else</span> False <span class="br0">&#125;</span></pre></div>
<p><br />
</p><p><br />
</p>
<a name=".60"></a><h2> <span class="mw-headline">24  ` </span></h2>
<p>A function enclosed in back ticks "`" can be used as an infix operator.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="nu0">2</span> `<span class="kw3">subtract</span>` <span class="nu0">10</span></pre></div>
<p>is the same as
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw3">subtract</span> <span class="nu0">2</span> <span class="nu0">10</span></pre></div>
<a name=".7B.2C_.7D"></a><h2> <span class="mw-headline">25  {, } </span></h2>
<ul><li> Explicit block (disable <a href="/haskellwiki/Layout" title="Layout">layout</a>), possibly with ";" .
</li></ul>
<ul><li> Record update notation
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">changePrice <span class="sy0">::</span> Thing <span class="sy0">-&gt;</span> Price <span class="sy0">-&gt;</span> Thing
changePrice x new <span class="sy0">=</span> x <span class="br0">&#123;</span> price <span class="sy0">=</span> new <span class="br0">&#125;</span></pre></div>
<ul><li> Comments (see below)
</li></ul>
<a name=".7B-.2C_-.7D"></a><h2> <span class="mw-headline">26  {-, -} </span></h2>
<p>Everything between "{-" followed by a space and "-}" is a block comment.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="coMULTI">{-
hello
world
-}</span></pre></div>
<a name=".7C"></a><h2> <span class="mw-headline">27  | </span></h2>
<p>The "pipe" is used in several places
</p>
<ul><li> Data type definitions, "or"
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">data</span> <span class="kw4">Maybe</span> a <span class="sy0">=</span> Just a <span class="sy0">|</span> Nothing</pre></div>
<ul><li> List comprehensions, "where"
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">squares <span class="sy0">=</span> <span class="br0">&#91;</span>a<span class="sy0">*</span>a <span class="sy0">|</span> a <span class="sy0">&lt;-</span> <span class="br0">&#91;</span><span class="nu0">1</span><span class="sy0">..</span><span class="br0">&#93;</span><span class="br0">&#93;</span></pre></div>
<ul><li> Guards, "when"
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">safeTail x <span class="sy0">|</span> <span class="kw3">null</span> x    <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span>
           <span class="sy0">|</span> <span class="kw3">otherwise</span> <span class="sy0">=</span> <span class="kw3">tail</span> x</pre></div>
<ul><li> <a href="/haskellwiki/Functional_dependencies" class="mw-redirect" title="Functional dependencies">Functional dependencies</a>, "where"
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">class</span> Contains c elt <span class="sy0">|</span> c <span class="sy0">-&gt;</span> elt <span class="kw1">where</span>
   <span class="sy0">...</span></pre></div>
<a name=".7E"></a><h2> <span class="mw-headline">28  ~ </span></h2>
<ul><li> Lazy pattern bindings. Matching the pattern ~pat against a value always
</li></ul>
<p>suceeds, and matching will only diverge when one of the variables bound
in the pattern is used.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">f1<span class="sy0">,</span> f2 <span class="sy0">::</span> <span class="kw4">Maybe</span> <span class="kw4">Int</span> <span class="sy0">-&gt;</span> <span class="kw4">String</span>
f1 x <span class="sy0">=</span> <span class="kw1">case</span> x <span class="kw1">of</span> 
    Just n <span class="sy0">-&gt;</span> <span class="st0">&quot;Got it&quot;</span>
f2 x <span class="sy0">=</span> <span class="kw1">case</span> x <span class="kw1">of</span>
    <span class="sy0">~</span><span class="br0">&#40;</span>Just n<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="st0">&quot;Got it&quot;</span>
&nbsp;
<span class="br0">&#40;</span><span class="sy0">+++</span><span class="br0">&#41;</span><span class="sy0">,</span> <span class="br0">&#40;</span><span class="sy0">++++</span><span class="br0">&#41;</span> <span class="sy0">::</span> <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> b<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="br0">&#40;</span>c <span class="sy0">-&gt;</span> d<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="br0">&#40;</span>a<span class="sy0">,</span> c<span class="br0">&#41;</span> <span class="sy0">-&gt;</span> <span class="br0">&#40;</span>b<span class="sy0">,</span> d<span class="br0">&#41;</span> 
<span class="br0">&#40;</span>f <span class="sy0">+++</span> g<span class="br0">&#41;</span> <span class="sy0">~</span><span class="br0">&#40;</span>x<span class="sy0">,</span> y<span class="br0">&#41;</span> <span class="sy0">=</span> <span class="br0">&#40;</span>f x<span class="sy0">,</span> g y<span class="br0">&#41;</span>
<span class="br0">&#40;</span>f <span class="sy0">++++</span> g<span class="br0">&#41;</span> <span class="br0">&#40;</span>x<span class="sy0">,</span> y<span class="br0">&#41;</span> <span class="sy0">=</span> <span class="br0">&#40;</span>f x<span class="sy0">,</span> g y<span class="br0">&#41;</span></pre></div>
<p>Then we have:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">f1 Nothing
Exception: Non<span class="sy0">-</span>exhaustive patterns <span class="kw1">in</span> <span class="kw1">case</span>
&nbsp;
f2 Nothing
<span class="st0">&quot;Got it&quot;</span>
&nbsp;
<span class="br0">&#40;</span><span class="kw3">const</span> <span class="nu0">1</span> <span class="sy0">+++</span> <span class="kw3">const</span> <span class="nu0">2</span><span class="br0">&#41;</span> <span class="kw3">undefined</span>
<span class="br0">&#40;</span><span class="nu0">1</span><span class="sy0">,</span><span class="nu0">2</span><span class="br0">&#41;</span>
&nbsp;
<span class="br0">&#40;</span><span class="kw3">const</span> <span class="nu0">1</span> <span class="sy0">++++</span> <span class="kw3">const</span> <span class="nu0">2</span><span class="br0">&#41;</span> <span class="kw3">undefined</span>
Exception: <span class="kw2">Prelude</span><span class="sy0">.</span><span class="kw3">undefined</span></pre></div>
<p>For more details see <a href="http://en.wikibooks.org/wiki/Haskell/Laziness#Lazy_pattern_matching" class="external text" title="http://en.wikibooks.org/wiki/Haskell/Laziness#Lazy_pattern_matching" rel="nofollow">the Haskell Wikibook</a>.
</p>
<ul><li> Equality constraints.  Assert that two types in a context must be the same:
</li></ul>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">example <span class="sy0">::</span> F a <span class="sy0">~</span> b <span class="sy0">=&gt;</span> a <span class="sy0">-&gt;</span> b</pre></div>
<p>Here the type "F a" must be the same as the type "b", which allows one to constrain polymorphism (especially where type families are involved), but to a lesser extent than functional dependencies.  See <a href="/haskellwiki/Type_families#Equality_constraints" class="mw-redirect" title="Type families">Type Families</a>.
</p>
<a name="as"></a><h2> <span class="mw-headline">29  as </span></h2>
Renaming module imports. Like <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw1">qualified</span></div></div></div> and <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw1">hiding</span></div></div></div>, <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw1">as</span></div></div></div> is not a reserved word but may be used as function or variable name.
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">import</span> <span class="kw1">qualified</span> Data<span class="sy0">.</span>Map <span class="kw1">as</span> M
&nbsp;
main <span class="sy0">=</span> <span class="kw3">print</span> <span class="br0">&#40;</span>M<span class="sy0">.</span>empty <span class="sy0">::</span> M<span class="sy0">.</span>Map <span class="kw4">Int</span> <span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#41;</span></pre></div>
<a name="case.2C_of"></a><h2> <span class="mw-headline">30  <span id="case">case</span>, <span id="of">of</span> </span></h2>
<p>A case expression has the general form
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">case</span> e <span class="kw1">of</span> <span class="br0">&#123;</span> p1 match1&nbsp;; <span class="sy0">...</span>&nbsp;; pn matchn <span class="br0">&#125;</span></pre></div>
<p>where each <code>match</code><sub>i</sub> is of the general form
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="sy0">|</span> g1 <span class="sy0">-&gt;</span> e1
  <span class="sy0">...</span>
<span class="sy0">|</span> gm <span class="sy0">-&gt;</span> em
    <span class="kw1">where</span> decls</pre></div>
<p>Each alternative consists of patterns <code>p</code><sub>i</sub> and their matches, <code>match</code><sub>i</sub>. Each
<code>match</code><sub>i</sub> in turn consists of a sequence of pairs of guards <code>g</code><sub>ij</sub> and bodies <code>e</code><sub>ij</sub>
(expressions), followed by optional bindings (<code>decls</code><sub>i</sub>) that scope over all
of the guards and expressions of the alternative. An alternative of the
form
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">pat <span class="sy0">-&gt;</span> <span class="kw3">exp</span> <span class="kw1">where</span> decls</pre></div>
<p>is treated as shorthand for:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">pat <span class="sy0">|</span> True <span class="sy0">-&gt;</span> <span class="kw3">exp</span>
    <span class="kw1">where</span> decls</pre></div>
<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 <code>e</code>
against the individual alternatives. The alternatives are tried
sequentially, from top to bottom. If <code>e</code> 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 <code>decls</code><sub>i</sub>&nbsp; in the <code>where</code> clause associated with that alternative. If one
of the guards evaluates to <code>True</code>, the corresponding right-hand side is
evaluated in the same environment as the guard. If all the guards
evaluate to <code>False</code>, matching continues with the next alternative. If no
match succeeds, the result is _|_.
</p>
<a name="class"></a><h2> <span class="mw-headline">31  class </span></h2>
<p>A <a href="http://haskell.org/onlinereport/decls.html#class-decls" class="external text" title="http://haskell.org/onlinereport/decls.html#class-decls" rel="nofollow">class declaration</a> 
introduces a new type class and the overloaded operations that must be
supported by any type that is an instance of that class.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">class</span> <span class="kw4">Num</span> a  <span class="kw1">where</span>
    <span class="br0">&#40;</span><span class="sy0">+</span><span class="br0">&#41;</span>    <span class="sy0">::</span> a <span class="sy0">-&gt;</span> a <span class="sy0">-&gt;</span> a
    <span class="kw3">negate</span> <span class="sy0">::</span> a <span class="sy0">-&gt;</span> a</pre></div>
<a name="data"></a><h2> <span class="mw-headline">32  data </span></h2>
<p>The <a href="http://haskell.org/onlinereport/decls.html#user-defined-datatypes" class="external text" title="http://haskell.org/onlinereport/decls.html#user-defined-datatypes" rel="nofollow">data</a> 
declaration is how one introduces new algebraic data <a href="/haskellwiki/Type" title="Type">types</a> into
Haskell.  For example:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">data</span> Set a <span class="sy0">=</span> NilSet 
           <span class="sy0">|</span> ConsSet a <span class="br0">&#40;</span>Set a<span class="br0">&#41;</span></pre></div>
<p>Another example, to create a datatype to hold an <a href="/haskellwiki/Abstract_syntax_tree" title="Abstract syntax tree">abstract syntax tree</a> for an expression, one could use:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">data</span> Exp <span class="sy0">=</span> Ebin   Operator Exp Exp 
          <span class="sy0">|</span> Eunary Operator Exp 
          <span class="sy0">|</span> Efun   FunctionIdentifier <span class="br0">&#91;</span>Exp<span class="br0">&#93;</span> 
          <span class="sy0">|</span> Eid    SimpleIdentifier</pre></div>
<p>where the <a href="/haskellwiki/Type" title="Type">types</a> <code>Operator, FunctionIdentifier</code> and <code>SimpleIdentifier</code> are defined elsewhere. 
</p><p>See the page on <a href="/haskellwiki/Type" title="Type">types</a> for more information, links and examples.
</p>
<a name="data_family"></a><h2> <span class="mw-headline">33  data family </span></h2>
<p>Declares a datatype family (see <a href="/haskellwiki/Type_families" class="mw-redirect" title="Type families">type families</a>). GHC language extension.
</p>
<a name="data_instance"></a><h2> <span class="mw-headline">34  data instance </span></h2>
<p>Declares a datatype family instance (see <a href="/haskellwiki/Type_families" class="mw-redirect" title="Type families">type families</a>). GHC language extension.
</p><p><br />
</p>
<a name="default"></a><h2> <span class="mw-headline">35  default </span></h2>
<p>Ambiguities in the class Num are most common, so Haskell provides
a way to resolve them---with a default declaration:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">default</span> <span class="br0">&#40;</span><span class="kw4">Int</span><span class="br0">&#41;</span></pre></div>
<p>Only one default declaration is permitted per module, and its effect is
limited to that module. If no default declaration is given in a module
then it assumed to be:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">default</span> <span class="br0">&#40;</span><span class="kw4">Integer</span><span class="sy0">,</span> <span class="kw4">Double</span><span class="br0">&#41;</span></pre></div>
<a name="deriving"></a><h2> <span class="mw-headline">36  deriving </span></h2>
<p>data and newtype declarations contain an optional deriving form. If the
form is included, then derived instance declarations are automatically
generated for the datatype in each of the named classes.
</p><p><a href="http://haskell.org/onlinereport/decls.html#derived-decls" class="external text" title="http://haskell.org/onlinereport/decls.html#derived-decls" rel="nofollow">Derived instances</a> provide convenient commonly-used operations for user-defined
datatypes. For example, derived instances for datatypes in the class Eq
define the operations == and /=, freeing the programmer from the need to
define them.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">data</span> T <span class="sy0">=</span> A
       <span class="sy0">|</span> B
       <span class="sy0">|</span> C
       <span class="kw1">deriving</span> <span class="br0">&#40;</span><span class="kw4">Eq</span><span class="sy0">,</span> <span class="kw4">Ord</span><span class="sy0">,</span> <span class="kw4">Show</span><span class="br0">&#41;</span></pre></div>
<p>In the case of newtypes, GHC extends this mechanism to <a href="/haskellwiki/Cunning_Newtype_Deriving" title="Cunning Newtype Deriving">Cunning Newtype Deriving</a>.
</p>
<a name="deriving_instance"></a><h2> <span class="mw-headline">37  deriving instance </span></h2>
<p>Standalone deriving (GHC language extension).
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="coMULTI">{-# LANGUAGE StandaloneDeriving #-}</span>
<span class="kw1">data</span> A <span class="sy0">=</span> A
&nbsp;
<span class="kw1">deriving</span> <span class="kw1">instance</span> <span class="kw4">Show</span> A</pre></div>
<a name="do"></a><h2> <span class="mw-headline">38  do </span></h2>
<p>Syntactic sugar for use with monadic expressions. For example:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">do</span> <span class="br0">&#123;</span> x&nbsp;; result <span class="sy0">&lt;-</span> y&nbsp;; foo result <span class="br0">&#125;</span></pre></div>
<p>is shorthand for:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">x <span class="sy0">&gt;&gt;</span> 
 y <span class="sy0">&gt;&gt;=</span> \result <span class="sy0">-&gt;</span>
 foo result</pre></div>
<a name="forall"></a><h2> <span class="mw-headline">39  forall </span></h2>
<p>This is a GHC/Hugs extension, and as such is not portable Haskell 98. 
It is only a reserved word within types. 
</p><p>Type variables in a Haskell type expression are all assumed to be
universally quantified; there is no explicit syntax for universal
quantification, in standard Haskell 98. For example, the type expression
</p>
<div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;">a <span class="sy0">-&gt;</span> a</div></div></div> denotes the type <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw1">forall</span> a<span class="sy0">.</span> a <span class="sy0">-&gt;</span>a</div></div></div>. 
<p>For clarity, however, we often write quantification explicitly when
discussing the types of Haskell programs. When we write an explicitly
quantified type, the scope of the forall extends as far to the right as
possible; for example, 
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">forall</span> a<span class="sy0">.</span> a <span class="sy0">-&gt;</span> a</pre></div>
<p>means 
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">forall</span> a<span class="sy0">.</span> <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> a<span class="br0">&#41;</span></pre></div>
GHC <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html#type-synonyms" class="external text" title="http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html#type-synonyms" rel="nofollow">introduces</a> a <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw1">forall</span></div></div></div> keyword, allowing explicit quantification, for example, to encode 
<p><a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html#existential-quantification" class="external text" title="http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html#existential-quantification" rel="nofollow">existential types</a>: 
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">data</span> Foo <span class="sy0">=</span> <span class="kw1">forall</span> a<span class="sy0">.</span> MkFoo a <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> <span class="kw4">Bool</span><span class="br0">&#41;</span>
         <span class="sy0">|</span> Nil
&nbsp;
MkFoo <span class="sy0">::</span> <span class="kw1">forall</span> a<span class="sy0">.</span> a <span class="sy0">-&gt;</span> <span class="br0">&#40;</span>a <span class="sy0">-&gt;</span> <span class="kw4">Bool</span><span class="br0">&#41;</span> <span class="sy0">-&gt;</span> Foo
Nil   <span class="sy0">::</span> Foo
&nbsp;
<span class="br0">&#91;</span>MkFoo <span class="nu0">3</span> <span class="kw3">even</span><span class="sy0">,</span> MkFoo 'c' isUpper<span class="br0">&#93;</span> <span class="sy0">::</span> <span class="br0">&#91;</span>Foo<span class="br0">&#93;</span></pre></div>
<a name="foreign"></a><h2> <span class="mw-headline">40  foreign </span></h2>
A keyword for the <a href="/haskellwiki/Foreign_Function_Interface" title="Foreign Function Interface">Foreign Function Interface</a> (commonly called the FFI) that introduces either a <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;">foreign <span class="kw1">import</span></div></div></div> declaration, which makes a function from a non-Haskell library available in a Haskell program, or a <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;">foreign export</div></div></div> declaration, which allows a function from a Haskell module to be called in non-Haskell contexts.
<a name="hiding"></a><h2> <span class="mw-headline">41  hiding </span></h2>
<p>When importing modules, without introducing a name into scope, entities can be excluded by using the form
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">hiding</span> <span class="br0">&#40;</span>import1 <span class="sy0">,</span> <span class="sy0">...</span> <span class="sy0">,</span> importn <span class="br0">&#41;</span></pre></div>
<p>which specifies that all entities exported by the named module should be
imported except for those named in the list.
</p><p>For example:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">import</span> <span class="kw2">Prelude</span> <span class="kw1">hiding</span> <span class="br0">&#40;</span><span class="kw3">lookup</span><span class="sy0">,</span><span class="kw3">filter</span><span class="sy0">,</span><span class="kw3">foldr</span><span class="sy0">,</span><span class="kw3">foldl</span><span class="sy0">,</span><span class="kw3">null</span><span class="sy0">,</span><span class="kw3">map</span><span class="br0">&#41;</span></pre></div>
<a name="if.2C_then.2C_else"></a><h2> <span class="mw-headline">42  <span id="if">if</span>, <span id="then">then</span>, <span id="else">else</span> </span></h2>
<p>A conditional expression has the form:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">if</span> e1 <span class="kw1">then</span> e2 <span class="kw1">else</span> e3</pre></div>
<p>and returns the value of e2 if the value of e1 is True, e3 if e1 is False, and _|_ otherwise.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw3">max</span> a b <span class="sy0">=</span> <span class="kw1">if</span> a <span class="sy0">&gt;</span> b <span class="kw1">then</span> a <span class="kw1">else</span> b</pre></div>
<a name="import"></a><h2> <span class="mw-headline">43  import </span></h2>
<p><a href="http://haskell.org/onlinereport/modules.html" class="external text" title="http://haskell.org/onlinereport/modules.html" rel="nofollow">Modules</a> may reference
other modules via explicit import declarations, each giving the name of
a module to be imported and specifying its entities to be imported.
</p><p>For example:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">module</span> Main <span class="kw1">where</span>
    <span class="kw1">import</span> A
    <span class="kw1">import</span> B
    main <span class="sy0">=</span> A<span class="sy0">.</span>f <span class="sy0">&gt;&gt;</span> B<span class="sy0">.</span>f
&nbsp;
  <span class="kw1">module</span> A <span class="kw1">where</span>
    f <span class="sy0">=</span> <span class="sy0">...</span>
&nbsp;
  <span class="kw1">module</span> B <span class="kw1">where</span>
    f <span class="sy0">=</span> <span class="sy0">...</span></pre></div>
<p>See also <a href="#as" title=""> as</a>, <a href="#hiding" title=""> hiding</a> , <a href="#qualified" title=""> qualified</a> and the page <a href="/haskellwiki/Import" title="Import">Import</a>
</p>
<a name="infix.2C_infixl.2C_infixr"></a><h2> <span class="mw-headline">44  <span id="infix">infix</span>, <span id="infixl">infixl</span>, <span id="infixr">infixr</span> </span></h2>
<p>A <a href="http://haskell.org/onlinereport/decls.html" class="external text" title="http://haskell.org/onlinereport/decls.html" rel="nofollow">fixity declaration</a> gives
the fixity and binding precedence of one or more operators. The integer
in a fixity declaration must be in the range 0 to 9. A fixity
declaration may appear anywhere that a <a href="/haskellwiki/Type_signature" title="Type signature">type signature</a> appears and, like
a type signature, declares a property of a particular operator.
</p><p>There are three kinds of fixity, non-, left- and right-associativity
(infix, infixl, and infixr, respectively), and ten precedence levels, 0
to 9 inclusive (level 0 binds least tightly, and level 9 binds most
tightly).
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">module</span> Bar <span class="kw1">where</span>
    <span class="kw1">infixr</span> <span class="nu0">7</span> `op`
    op <span class="sy0">=</span> <span class="sy0">...</span></pre></div>
<a name="instance"></a><h2> <span class="mw-headline">45  instance </span></h2>
<p>An instance declaration declares that a type is an instance of a class
and includes the definitions of the overloaded operations - called class
methods - instantiated on the named type.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">instance</span> <span class="kw4">Num</span> <span class="kw4">Int</span>  <span class="kw1">where</span>
    x <span class="sy0">+</span> y       <span class="sy0">=</span>  addInt x y
    <span class="kw3">negate</span> x    <span class="sy0">=</span>  negateInt x</pre></div>
<a name="let.2C_in"></a><h2> <span class="mw-headline">46  <span id="let">let</span>, <span id="in">in</span> </span></h2>
<p>Let expressions have the general form:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">let</span> <span class="br0">&#123;</span> d1&nbsp;; <span class="sy0">...</span>&nbsp;; dn <span class="br0">&#125;</span> <span class="kw1">in</span> e</pre></div>
<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>
Within <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw1">do</span></div></div></div>-blocks or list comprehensions <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw1">let</span> <span class="br0">&#123;</span> d1&nbsp;; <span class="sy0">...</span>&nbsp;; dn <span class="br0">&#125;</span></div></div></div> without <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw1">in</span></div></div></div> serves to indroduce local bindings.
<a name="mdo"></a><h2> <span class="mw-headline">47  <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#id3017137" class="external text" title="http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#id3017137" rel="nofollow">mdo</a> </span></h2>
The recursive <div class="inline-code"><div dir="ltr" style="text-align: left;"><div class="source-haskell" style="font-family: monospace;"><span class="kw1">do</span></div></div></div> keyword enabled by -fglasgow-exts
<a name="module"></a><h2> <span class="mw-headline">48  module </span></h2>
<p>Taken from: <a href="http://www.haskell.org/tutorial/modules.html" class="external text" title="http://www.haskell.org/tutorial/modules.html" rel="nofollow">A Gentle Introduction to Haskell, Version 98</a>
</p><p>Technically speaking, a module is really just one big declaration which begins with the keyword module; here's an example for a module whose name is Tree:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">module</span> Tree <span class="br0">&#40;</span> Tree<span class="br0">&#40;</span>Leaf<span class="sy0">,</span>Branch<span class="br0">&#41;</span><span class="sy0">,</span> fringe <span class="br0">&#41;</span> <span class="kw1">where</span>
&nbsp;
<span class="kw1">data</span> Tree a                <span class="sy0">=</span> Leaf a <span class="sy0">|</span> Branch <span class="br0">&#40;</span>Tree a<span class="br0">&#41;</span> <span class="br0">&#40;</span>Tree a<span class="br0">&#41;</span> 
&nbsp;
fringe <span class="sy0">::</span> Tree a <span class="sy0">-&gt;</span> <span class="br0">&#91;</span>a<span class="br0">&#93;</span>
fringe <span class="br0">&#40;</span>Leaf x<span class="br0">&#41;</span>            <span class="sy0">=</span> <span class="br0">&#91;</span>x<span class="br0">&#93;</span>
fringe <span class="br0">&#40;</span>Branch left right<span class="br0">&#41;</span> <span class="sy0">=</span> fringe left <span class="sy0">++</span> fringe right</pre></div>
<a name="newtype"></a><h2> <span class="mw-headline">49  newtype </span></h2>
<p>The <code>newtype</code> declaration is how one introduces a renaming for an algebraic data <a href="/haskellwiki/Type" title="Type">type</a> into Haskell. This is different from <code>type</code> below, as a <code>newtype</code> requires a new <a href="/haskellwiki/Constructor" title="Constructor">constructor</a> as well. As an example, when writing a compiler
one sometimes further qualifies <code>Identifier</code>s to assist in type safety checks:
</p>
<pre>newtype SimpleIdentifier = SimpleIdentifier Identifier
newtype FunctionIdentifier = FunctionIdentifier Identifier
</pre>
<p>Most often, one supplies <a href="/haskellwiki/Smart_constructors" title="Smart constructors">smart constructors</a> and <a href="/haskellwiki/index.php?title=Destructor&amp;action=edit" class="new" title="Destructor">destructors</a> for these to ease working with them.
</p><p>See the page on <a href="/haskellwiki/Type" title="Type">types</a> for more information, links and examples.
</p><p>For the differences between <code>newtype</code> and <code>data</code>, see <a href="/haskellwiki/Newtype" title="Newtype">Newtype</a>.
</p>
<a name="proc"></a><h2> <span class="mw-headline">50  proc </span></h2>
<p>proc (arrow abstraction)
is a kind of lambda, except that it constructs an arrow instead of a function.
</p><p><a href="/haskellwiki/Arrow_notation" title="Arrow notation">Arrow notation</a>
</p>
<a name="qualified"></a><h2> <span class="mw-headline">51  qualified </span></h2>
<p>Used to import a module, but not introduce a name into scope. For example, Data.Map exports lookup, which would clash with the Prelude version of lookup, to fix this:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">import</span> <span class="kw1">qualified</span> Data<span class="sy0">.</span>Map
&nbsp;
f x <span class="sy0">=</span> <span class="kw3">lookup</span> x <span class="co1">-- use the Prelude version</span>
g x <span class="sy0">=</span> Data<span class="sy0">.</span>Map<span class="sy0">.</span><span class="kw3">lookup</span> x <span class="co1">-- use the Data.Map version</span></pre></div>
<p>Of course, Data.Map is a bit of a mouthful, so qualified also allows the use of as.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">import</span> <span class="kw1">qualified</span> Data<span class="sy0">.</span>Map <span class="kw1">as</span> M
&nbsp;
f x <span class="sy0">=</span> <span class="kw3">lookup</span> x <span class="co1">-- use Prelude version</span>
g x <span class="sy0">=</span> M<span class="sy0">.</span><span class="kw3">lookup</span> x <span class="co1">-- use Data.Map version</span></pre></div>
<a name="rec"></a><h2> <span class="mw-headline">52  rec </span></h2>
<p>The <a href="http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#mdo-notation" class="external text" title="http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#mdo-notation" rel="nofollow">rec</a> keyword can be used when the <code>-XDoRec</code> flag is given; it allows recursive bindings in a do-block.
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="coMULTI">{-# LANGUAGE DoRec #-}</span>
justOnes <span class="sy0">=</span> <span class="kw1">do</span> <span class="br0">&#123;</span> rec <span class="br0">&#123;</span> xs <span class="sy0">&lt;-</span> Just <span class="br0">&#40;</span><span class="nu0">1</span>:xs<span class="br0">&#41;</span> <span class="br0">&#125;</span>
             &nbsp;; <span class="kw3">return</span> <span class="br0">&#40;</span><span class="kw3">map</span> <span class="kw3">negate</span> xs<span class="br0">&#41;</span> <span class="br0">&#125;</span></pre></div>
<a name="type"></a><h2> <span class="mw-headline">53  type </span></h2>
<p>The <code>type</code> declaration is how one introduces an alias for an algebraic data <a href="/haskellwiki/Type" title="Type">type</a> into Haskell. As an example, when writing a compiler
one often creates an alias for identifiers:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">type</span> Identifier <span class="sy0">=</span> <span class="kw4">String</span></pre></div>
<p>This allows you to use <code>Identifer</code> wherever you had used <code>String</code> and if something is of type <code>Identifier</code> it
may be used wherever a <code>String</code> is expected.
</p><p>See the page on <a href="/haskellwiki/Type" title="Type">types</a> for more information, links and examples.
</p><p>Some common <code>type</code> declarations in the Prelude include:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">type</span> FilePath <span class="sy0">=</span> <span class="kw4">String</span>
<span class="kw1">type</span> <span class="kw4">String</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="kw4">Char</span><span class="br0">&#93;</span>
<span class="kw1">type</span> <span class="kw4">Rational</span> <span class="sy0">=</span> Ratio <span class="kw4">Integer</span>
<span class="kw1">type</span> <span class="kw4">ReadS</span> a <span class="sy0">=</span> <span class="kw4">String</span> <span class="sy0">-&gt;</span> <span class="br0">&#91;</span><span class="br0">&#40;</span>a<span class="sy0">,</span><span class="kw4">String</span><span class="br0">&#41;</span><span class="br0">&#93;</span>
<span class="kw1">type</span> <span class="kw4">ShowS</span> <span class="sy0">=</span> <span class="kw4">String</span> <span class="sy0">-&gt;</span> <span class="kw4">String</span></pre></div>
<a name="type_family"></a><h2> <span class="mw-headline">54  type family </span></h2>
<p>Declares a type synonym family (see <a href="/haskellwiki/Type_families" class="mw-redirect" title="Type families">type families</a>). GHC language extension.
</p>
<a name="type_instance"></a><h2> <span class="mw-headline">55  type instance </span></h2>
<p>Declares a type synonym family instance (see <a href="/haskellwiki/Type_families" class="mw-redirect" title="Type families">type families</a>). GHC language extension.
</p><p><br />
</p>
<a name="where"></a><h2> <span class="mw-headline">56  where </span></h2>
<p>Used to introduce a module, instance, class or <a href="/haskellwiki/GADT" class="mw-redirect" title="GADT">GADT</a>:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell"><span class="kw1">module</span> Main <span class="kw1">where</span>
&nbsp;
<span class="kw1">class</span> <span class="kw4">Num</span> a <span class="kw1">where</span>
    <span class="sy0">...</span>
&nbsp;
<span class="kw1">instance</span> <span class="kw4">Num</span> <span class="kw4">Int</span>  <span class="kw1">where</span>
    <span class="sy0">...</span>
&nbsp;
<span class="kw1">data</span> Something a <span class="kw1">where</span>
   <span class="sy0">...</span></pre></div>
<p>And to bind local variables:
</p>
<div dir="ltr" style="text-align: left;"><pre class="source-haskell">f x <span class="sy0">=</span> y
    <span class="kw1">where</span> y <span class="sy0">=</span> x <span class="sy0">*</span> <span class="nu0">2</span>
&nbsp;
g z <span class="sy0">|</span> z <span class="sy0">&gt;</span> <span class="nu0">2</span> <span class="sy0">=</span> y
    <span class="kw1">where</span> y <span class="sy0">=</span> x <span class="sy0">*</span> <span class="nu0">2</span></pre></div>

<!-- 
NewPP limit report
Preprocessor node count: 430/1000000
Post-expand include size: 0/2097152 bytes
Template argument size: 0/2097152 bytes
-->

<!-- Saved in parser cache with key wikidb:pcache:idhash:1373-0!1!0!1!en!2!edit=0 and timestamp 20120909073103 -->
<div class="printfooter">
Retrieved from "<a href="http://www.haskell.org/haskellwiki/Keywords">http://www.haskell.org/haskellwiki/Keywords</a>"</div>
			<p class='catlinks'><a href="/haskellwiki/Special:Categories" title="Special:Categories">Category</a>: <span dir='ltr'><a href="/haskellwiki/Category:Language" title="Category:Language">Language</a></span></p>			<!-- end content -->
						<div class="visualClear"></div>
		</div>
	</div>
		</div></div>
		<div id="column-one">
	<script type="text/javascript"> if (window.isMSIE55) fixalpha(); </script>
	<div class='generated-sidebar portlet' id='p-navigation'>
		<h5>Navigation</h5>
		<div class='pBody'>
			<ul>
				<li id="n-mainpage"><a href="/haskellwiki/Haskell" title="Visit the Main Page [z]" accesskey="z">Haskell</a></li>
				<li id="n-portal"><a href="/haskellwiki/HaskellWiki:Community" title="About the project, what you can do, where to find things">Wiki community</a></li>
				<li id="n-recentchanges"><a href="/haskellwiki/Special:Recentchanges" title="The list of recent changes in the wiki. [r]" accesskey="r">Recent changes</a></li>
				<li id="n-randompage"><a href="/haskellwiki/Special:Random" title="Load a random page [x]" accesskey="x">Random page</a></li>
			</ul>
		</div>
	</div>
	<div class="portlet" id="p-tb">
		<h5>Toolbox</h5>
		<div class="pBody">
			<ul>
				<li id="t-whatlinkshere"><a href="/haskellwiki/Special:Whatlinkshere/Keywords" title="List of all wiki pages that link here [j]" accesskey="j">What links here</a></li>
				<li id="t-recentchangeslinked"><a href="/haskellwiki/Special:Recentchangeslinked/Keywords" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li>
<li id="t-upload"><a href="/haskellwiki/Special:Upload" title="Upload files [u]" accesskey="u">Upload file</a></li>
<li id="t-specialpages"><a href="/haskellwiki/Special:Specialpages" title="List of all special pages [q]" accesskey="q">Special pages</a></li>
				<li id="t-print"><a href="/haskellwiki/index.php?title=Keywords&amp;printable=yes" rel="alternate" title="Printable version of this page [p]" accesskey="p">Printable version</a></li>				<li id="t-permalink"><a href="/haskellwiki/index.php?title=Keywords&amp;oldid=47894" title="Permanent link to this version of the page">Permanent link</a></li>			</ul>
		</div>
	</div>
		</div><!-- end of the left (by default at least) column -->
			<div class="visualClear"></div>
			<div id="footer">
				<div id="f-poweredbyico"><a href="http://www.mediawiki.org/"><img src="/wikistatic/skins//common/images/poweredby_mediawiki_88x31.png" alt="Powered by MediaWiki" /></a></div>
			<ul id="f-list">
					<li id="lastmod"> This page was last modified 16:08, 4 August 2012.</li>
					<li id="viewcount">This page has been accessed 64,043 times.</li>
					<li id="copyright">Recent content is available under <a href="/haskellwiki/HaskellWiki:Copyrights" title="HaskellWiki:Copyrights">a simple permissive license</a>.</li>
					<li id="privacy"><a href="/haskellwiki/HaskellWiki:Privacy_policy" title="HaskellWiki:Privacy policy">Privacy policy</a></li>
					<li id="about"><a href="/haskellwiki/HaskellWiki:About" title="HaskellWiki:About">About HaskellWiki</a></li>
					<li id="disclaimer"><a href="/haskellwiki/HaskellWiki:General_disclaimer" title="HaskellWiki:General disclaimer">Disclaimers</a></li>
			</ul>
		</div>
</div>

		<script type="text/javascript">if (window.runOnloadHook) runOnloadHook();</script>
<!-- Served in 0.099 secs. --><script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-15375175-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</body></html>
