-
Notifications
You must be signed in to change notification settings - Fork 0
/
Eta-Core.html
36 lines (36 loc) · 6.63 KB
/
Eta-Core.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!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"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Eta.Core</title><link href="ocean.css" rel="stylesheet" type="text/css" title="Ocean" /><script src="haddock-util.js" type="text/javascript"></script><script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script><script type="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_Eta-Core.html");};
//]]>
</script></head><body class="no-frame"><div id="package-header"><ul class="links" id="page-menu"><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul><p class="caption empty"> </p></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>Safe</td></tr></table><p class="caption">Eta.Core</p></div><div id="description"><p class="caption">Description</p><div class="doc"><ul><li>Eta Core</li></ul></div></div><div id="synopsis"><p id="control.syn" class="caption expander" onclick="toggleSection('syn')">Synopsis</p><ul id="section.syn" class="hide" onclick="toggleSection('syn')"><li class="src short"><a href="#v:-124--62-">(|>)</a> :: a -> (a -> b) -> b</li><li class="src short"><a href="#v:-60--124-">(<|)</a> :: (a -> b) -> a -> b</li><li class="src short"><a href="#v:-36-">($)</a> :: (a -> b) -> a -> b</li><li class="src short"><a href="#v:flip">flip</a> :: (a -> b -> c) -> b -> a -> c</li><li class="src short"><a href="#v:die">die</a> :: <a href="Eta-Types-String.html#t:String">String</a> -> a</li><li class="src short"><a href="#v:undefined">undefined</a> :: a</li><li class="src short"><a href="#v:stopIfUndefined">stopIfUndefined</a> :: a -> b -> b</li><li class="src short"><a href="#v:constantly">constantly</a> :: a -> b -> a</li></ul></div><div id="interface"><h1>Documentation</h1><div class="doc"><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>import Eta.Classes.Num
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>import Eta.Classes.Functor
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>import Eta.Classes.Show
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>import Eta.Types.IO
</code></strong></pre></div><div class="top"><p class="src"><a id="v:-124--62-" class="def">(|>)</a> :: a -> (a -> b) -> b <a href="#v:-124--62-" class="selflink">#</a></p><div class="doc"><p>Pipe operator. Functions can be applied using the pipe operator,
reducing parentheses and increasing the code readability.</p><p>Instead of writing</p><pre> (printLine (join ", " (sort names)))
</pre><p>Use the pipe operator:</p><pre> names
|> sort
|> join ", "
|> printLine
</pre></div></div><div class="top"><p class="src"><a id="v:-60--124-" class="def">(<|)</a> :: (a -> b) -> a -> b <a href="#v:-60--124-" class="selflink">#</a></p><div class="doc"><p>Pipe backwards operator.
Applies the function of the left to the value of the right.</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>(+ 2) <| 1
</code></strong>3
</pre></div></div><div class="top"><p class="src"><a id="v:-36-" class="def">($)</a> :: (a -> b) -> a -> b <a href="#v:-36-" class="selflink">#</a></p><div class="doc"><p>Application operator.
Synonymous to (<|), useful for skipping a level of parentheses.</p><p>It can be read as <em>"enclose in parentheses from here to the end of the expression."</em></p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>(print $ show 4)
</code></strong>4
</pre></div></div><div class="top"><p class="src"><a id="v:flip" class="def">flip</a> :: (a -> b -> c) -> b -> a -> c <a href="#v:flip" class="selflink">#</a></p><div class="doc"><p>Flips the arguments of a function</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>subtract a b = a - b
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>inverseSubtract = flip subtract
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>subtract 3 2
</code></strong>1
<code class="prompt">>>> </code><strong class="userinput"><code>inverseSubtract 3 2
</code></strong>-1
</pre></div></div><div class="top"><p class="src"><a id="v:die" class="def">die</a> :: <a href="Eta-Types-String.html#t:String">String</a> -> a <a href="#v:die" class="selflink">#</a></p><div class="doc"><div class="warning"><p>Warning: Partial functions should be avoided</p></div><p>Stops execution and displays an error message.</p></div></div><div class="top"><p class="src"><a id="v:undefined" class="def">undefined</a> :: a <a href="#v:undefined" class="selflink">#</a></p><div class="doc"><div class="warning"><p>Warning: Partial functions should be avoided</p></div><p>A value that can be of any type. The compiler will recognize this
and insert an error message appropriate to the context where it
appears.</p><p><em>Usually, also called <strong>Bottom</strong></em></p></div></div><div class="top"><p class="src"><a id="v:stopIfUndefined" class="def">stopIfUndefined</a> :: a -> b -> b <a href="#v:stopIfUndefined" class="selflink">#</a></p><div class="doc"><p>Returns <code><a href="Eta-Core.html#v:undefined">undefined</a></code> if <code>a</code> is <code><a href="Eta-Core.html#v:undefined">undefined</a></code>, otherwise returns <code>b</code></p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>stopIfUndefined 1 2
</code></strong>2
</pre></div></div><div class="top"><p class="src"><a id="v:constantly" class="def">constantly</a> :: a -> b -> a <a href="#v:constantly" class="selflink">#</a></p><div class="doc"><p>Constructs a function that returns the same output for
the same input</p><pre class="screen"><code class="prompt">>>> </code><strong class="userinput"><code>universe = constantly 42
</code></strong><code class="prompt">>>> </code><strong class="userinput"><code>universe 35
</code></strong>42
<code class="prompt">>>> </code><strong class="userinput"><code>map (constantly 10) [1..3]
</code></strong>[10,10,10]
</pre></div></div></div></div><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.17.4</p></div></body></html>