-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.html
166 lines (147 loc) · 5.89 KB
/
install.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<title>A Taste of Haskell - Getting Started</title>
<meta name="author" content="Sergio de Carvalho">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/moon.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section>
<h1>A Taste of Haskell</h1>
<h2>Getting Started with <em>Stack</em></h2>
</section>
<section>
<h2><em>Stack</em> - The Haskell Tool Stack</h2>
<ul>
<li>Cross-platform tool for developing Haskell projects</li>
<li>Installs <strong>GHC</strong> (Glasgow Haskell Compiler)</li>
<li>Downloads and installs package dependencies</li>
<li>Isolated environments for each project</li>
<li>Commands for building, testing, benchmarking, etc.</li>
</ul>
</section>
<section>
<h2>Installing Stack</h2>
<p>On Linux, MacOs, run from a terminal</p>
<pre><code class="nohighlight" data-trim data-noescape>
<strong>curl -sSL https://get.haskellstack.org/ | sh</strong>
</code></pre>
<p><em>or</em></p>
<pre><code class="nohighlight" data-trim data-noescape>
<strong>wget -qO- https://get.haskellstack.org/ | sh</strong>
</code></pre>
<p>On Windows, download and run <a href="https://get.haskellstack.org/stable/windows-x86_64-installer.exe" target="_blank">installer</a></p>
<p>Full instructions on <a href="https://docs.haskellstack.org" target="_blank">https://docs.haskellstack.org</a></p>
</section>
<section>
<h2>Hello World!</h2>
<p>Type the code in a file <strong><code>helloworld.hs</code></strong></p>
<pre><code class="haskell" data-trim data-noescape>
main = putStrLn "Hello, Haskell world!"
</code></pre>
<p>Compile and execute it with</p>
<pre><code class="nohighlight" data-trim data-noescape>
> <strong>stack ghc helloworld.hs</strong>
[1 of 1] Compiling Main ( helloworld.hs, helloworld.o )
Linking helloworld ...
> <strong>./helloworld</strong>
Hello, Haskell world!
</code></pre>
</section>
<section>
<h2>Interactive Haskell</h2>
<p>Start an interactive session (REPL)</p>
<pre><code class="nohighlight" data-trim data-noescape>
> <strong>stack ghci</strong>
Configuring GHCi with the following packages:
GHCi, version 8.2.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from ...
Prelude>
</code></pre>
<p>Load your Haskell program and call its <strong><code>main</code></strong> function</p>
<pre><code class="nohighlight" data-trim data-noescape>
Prelude> <strong>:load helloworld.hs</strong>
[1 of 1] Compiling Main ( helloworld.hs, interpreted )
Ok, modules loaded: Main.
*Main> <strong>main</strong>
Hello, Haskell world!
</code></pre>
</section>
<section>
<h2>Using GHCi</h2>
<p>Create functions and evaluate Haskell expressions</p>
<pre><code class="nohighlight" data-trim data-noescape>
Prelude> <strong>2 + 3 * (4 ^ 5)</strong>
3074
Prelude> <strong>1 < 2</strong>
True
Prelude> <strong>factorial 0 = 1; factorial n = n * factorial (n - 1)</strong>
Prelude> <strong>factorial 50</strong>
30414093201713378043612608166064768844377641568960512000000000000
</code></pre>
</section>
<section>
<h2>Multiline Input</h2>
<pre><code class="nohighlight" data-trim data-noescape>
Prelude> <strong>:{</strong>
Prelude| <strong>sumList [] = 0</strong>
Prelude| <strong>sumList (x:xs) = x + sumList xs</strong>
Prelude| <strong>:}</strong>
Prelude> <strong>sumList []</strong>
0
Prelude> <strong>sumList [1,2,3]</strong>
6
Prelude> <strong>sumList [1..10000]</strong>
50005000
</code></pre>
</section>
<section>
<h2>Basic GHCi Commands</h2>
<pre><code class="nohighlight" data-trim data-noescape>
<strong>:load <file></strong> or <strong>:l <file></strong> - load Haskell module
<strong>:reload</strong> or <strong>:r</strong> - reload Haskell module
<strong>:cd <dir></strong> - change directory
<strong>:! <cmd></strong> - execute shell command
<strong>:help</strong> or <strong>:?</strong> - list available commands
<strong>:quit</strong> or <strong>:q</strong> - quit GHCi
</code></pre>
</section>
<section>
<h1>Congratulations</h1>
<h2>You're ready to <a href="part1.html">start!</a></h2>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
Reveal.initialize({
transition: 'fade',
dependencies: [
{ src: 'plugin/markdown/marked.js' },
{ src: 'plugin/markdown/markdown.js' },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }
]
});
</script>
</body>
</html>