Skip to content

Commit e3f84bf

Browse files
authored
Merge pull request #100 from kRITZCREEK/generator
Generator
2 parents 3450c87 + 57dce98 commit e3f84bf

File tree

5 files changed

+13
-14
lines changed

5 files changed

+13
-14
lines changed

_site/index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ <h2>PureScript is a small strongly typed programming language that compiles to J
4545
<h3>Examples</h3>
4646
<div class="current example">
4747
<h4>Modifying the DOM</h4>
48-
<p>PureScript’s expressive type system and lightweight syntax make it simple to define <a href="https://leanpub.com/purescript/read#leanpub-auto-domain-specific-languages">domain-specific languages</a>, which can be used to solve problems like templating the DOM. Bindings also exist for libraries such as React and Angular.js.</p>
48+
<p>PureScript’s expressive type system and lightweight syntax make it simple to define <a href="https://leanpub.com/purescript/read#leanpub-auto-domain-specific-languages">domain-specific languages</a>, which can be used to solve problems like templating the DOM. Bindings also exist for libraries such as React and Virtual DOM.</p>
4949
<pre>
5050
<span class="kr">import</span> <span class="nn">Flare</span>
5151
<span class="kr">import</span> <span class="nn">Flare.Smolder</span>
@@ -56,8 +56,8 @@ <h4>Modifying the DOM</h4>
5656
<span class="nf">greet</span> name = h1 <span class="kt">$</span> text <span class="kt">$</span> <span class="s">"Hello, "</span> <span class="kt">&lt;&gt;</span> name <span class="kt">&lt;&gt;</span> <span class="s">"!"</span></pre>
5757
</div>
5858
<div class="example">
59-
<h4>HTML5 Canvas</h4>
60-
<p>Higher-order functions allow the developer to write fluent, expressive code. Here, higher-order functions are being used to capture some common patterns when <a href="https://leanpub.com/purescript/read#leanpub-auto-canvas-graphics">working with HTML5 canvas</a>, such as closing and filling paths.</p>
59+
<h4>HTML5 Canvas</h4>
60+
<p>Higher-order functions allow the developer to write fluent, expressive code. Here, higher-order functions are being used to capture some common patterns when <a href="https://leanpub.com/purescript/read#leanpub-auto-canvas-graphics">working with HTML5 canvas</a>, such as closing and filling paths.</p>
6161
<pre>
6262
<span class="kr">import</span> <span class="nn">Control.Apply</span>
6363
<span class="kr">import</span> <span class="nn">Graphics.Canvas.Free</span>
@@ -83,7 +83,7 @@ <h4>Callback Hell</h4>
8383
<span class="nf">loadModel</span> = <span class="kr">do</span>
8484
popular <- get <span class="s">"/products/popular"</span>
8585
products <- runPar $ for_ popular \product -> <span class="kt">Par</span> (get product.uri)
86-
return $ <span class="kt">Model</span> products</pre>
86+
pure (<span class="kt">Model</span> products)</pre>
8787
</div>
8888
<div class="example">
8989
<h4>Generative Testing</h4>

_site/learn/eff/index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ <h4 id="the-eff-monad">The Eff Monad</h4>
8282
<h4 id="extensible-records-and-extensible-effects">Extensible Records and Extensible Effects</h4>
8383
<p>We can inspect the type of <code>printRandom</code> by using the <code>:type command</code></p>
8484
<pre><code>&gt; import RandomExample
85-
&gt; :type main</code></pre>
86-
<p>The type of <code>main</code> will be printed to the console. You should see a type which looks like this:</p>
85+
&gt; :type printRandom</code></pre>
86+
<p>The type of <code>printRandom</code> will be printed to the console. You should see a type which looks like this:</p>
8787
<pre><code>forall e. Eff (console :: CONSOLE, random :: RANDOM | e) Unit</code></pre>
8888
<p>This type looks quite complicated, but is easily explained by analogy with PureScript’s extensible records system.</p>
8989
<p>Consider a simple function which uses extensible records:</p>
@@ -150,7 +150,7 @@ <h4 id="handlers-and-actions">Handlers and Actions</h4>
150150
<div class="sourceCode"><pre class="sourceCode haskell"><code class="sourceCode haskell"><span class="kw">import </span><span class="dt">Data.Either</span>
151151

152152
<span class="ot">dividePure ::</span> <span class="dt">Int</span> <span class="ot">-&gt;</span> <span class="dt">Int</span> <span class="ot">-&gt;</span> <span class="dt">Either</span> <span class="dt">String</span> <span class="dt">Int</span>
153-
dividePure n m <span class="fu">=</span> runPure (catchException (return <span class="fu">&lt;&lt;&lt;</span> <span class="dt">Left</span>) (<span class="dt">Right</span> <span class="fu">&lt;$&gt;</span> divide n m))</code></pre></div>
153+
dividePure n m <span class="fu">=</span> runPure (catchException (pure <span class="fu">&lt;&lt;&lt;</span> <span class="dt">Left</span> <span class="fu">&lt;&lt;&lt;</span> message) (<span class="dt">Right</span> <span class="fu">&lt;$&gt;</span> divide n m))</code></pre></div>
154154
<p>Note that <em>after</em> we use <code>catchException</code> to remove the <code>EXCEPTION</code> effect, there are no more effects remaining, so we can use <code>runPure</code> to evaluate the return value.</p>
155155
<h4 id="defining-new-effect-types">Defining New Effect Types</h4>
156156
<p>New effects can be defined using <code>foreign import data</code> just as in the case of types.</p>
@@ -166,7 +166,7 @@ <h4 id="defining-new-effect-types">Defining New Effect Types</h4>
166166
<span class="op">};</span></code></pre></div>
167167
<p>Note the type we give to <code>incrCounter</code>: we use a polymorphic type to make sure that <code>Counter</code> can be interleaved with other effects.</p>
168168
<p>Usually, we wouldn’t write a handler for the <code>Counter</code> effect, since we have no way to guarantee that the <code>globalCounter</code> hasn’t been modified. However, if we wanted to provide an unsafe “escape hatch” for <code>Counter</code>, we might do so as follows:</p>
169-
<pre class="purescript"><code>foreign import unsafeRunCounter :: forall e. Eff (counter :: COUNTER | e) a -&gt; Eff e a</code></pre>
169+
<pre class="purescript"><code>foreign import unsafeRunCounter :: forall e a. Eff (counter :: COUNTER | e) a -&gt; Eff e a</code></pre>
170170
<p>And in JavaScript:</p>
171171
<div class="sourceCode"><pre class="sourceCode javascript"><code class="sourceCode javascript"><span class="va">exports</span>.<span class="at">unsafeRunCounter</span> <span class="op">=</span> <span class="kw">function</span>(f) <span class="op">{</span>
172172
<span class="cf">return</span> f<span class="op">;</span>

_site/learn/index.html

-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ <h2 id="articles">Articles by Users</h2>
147147
<li><a href="http://blog.functorial.com/posts/2015-11-20-Thermite.html">Building a Task List Application with Thermite</a> <small>(at <a href="http://blog.functorial.com">blog.functorial.com</a>)</small></li>
148148
<li><a href="http://www.parsonsmatt.org/programming/2015/10/22/purescript_router.html">Using purescript-routing with purescript-halogen</a> <small>(at <a href="http://parsonsmatt.org">parsonsmatt.org</a>)</small></li>
149149
<li><a href="http://www.parsonsmatt.org/programming/2015/10/05/elm_vs_purescript_ii.html">The Elm Architecture in PureScript</a> <small>(at <a href="http://parsonsmatt.org">parsonsmatt.org</a>)</small></li>
150-
<li><a href="https://kritzcreek.github.io/tutorial/2015/10/07/playing-tic-tac-toe-with-purescript-signal/">Playing Tic-Tac-Toe using purescript-signal</a> <small>(at <a href="http://kritzcreek.github.io">kritzcreek.github.io</a>)</small></li>
151150
</ul>
152151

153152
<div>Please contribute your own content by <a href="https://github.com/purescript/purescript.github.io">sending a pull request</a>.</div>

index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h2>PureScript is a small strongly typed programming language that compiles to J
99
<h3>Examples</h3>
1010
<div class="current example">
1111
<h4>Modifying the DOM</h4>
12-
<p>PureScript’s expressive type system and lightweight syntax make it simple to define <a href="https://leanpub.com/purescript/read#leanpub-auto-domain-specific-languages">domain-specific languages</a>, which can be used to solve problems like templating the DOM. Bindings also exist for libraries such as React and Angular.js.</p>
12+
<p>PureScript’s expressive type system and lightweight syntax make it simple to define <a href="https://leanpub.com/purescript/read#leanpub-auto-domain-specific-languages">domain-specific languages</a>, which can be used to solve problems like templating the DOM. Bindings also exist for libraries such as React and Virtual DOM.</p>
1313
<pre>
1414
<span class="kr">import</span> <span class="nn">Flare</span>
1515
<span class="kr">import</span> <span class="nn">Flare.Smolder</span>
@@ -20,8 +20,8 @@ <h4>Modifying the DOM</h4>
2020
<span class="nf">greet</span> name = h1 <span class="kt">$</span> text <span class="kt">$</span> <span class="s">"Hello, "</span> <span class="kt">&lt;&gt;</span> name <span class="kt">&lt;&gt;</span> <span class="s">"!"</span></pre>
2121
</div>
2222
<div class="example">
23-
<h4>HTML5 Canvas</h4>
24-
<p>Higher-order functions allow the developer to write fluent, expressive code. Here, higher-order functions are being used to capture some common patterns when <a href="https://leanpub.com/purescript/read#leanpub-auto-canvas-graphics">working with HTML5 canvas</a>, such as closing and filling paths.</p>
23+
<h4>HTML5 Canvas</h4>
24+
<p>Higher-order functions allow the developer to write fluent, expressive code. Here, higher-order functions are being used to capture some common patterns when <a href="https://leanpub.com/purescript/read#leanpub-auto-canvas-graphics">working with HTML5 canvas</a>, such as closing and filling paths.</p>
2525
<pre>
2626
<span class="kr">import</span> <span class="nn">Control.Apply</span>
2727
<span class="kr">import</span> <span class="nn">Graphics.Canvas.Free</span>
@@ -47,7 +47,7 @@ <h4>Callback Hell</h4>
4747
<span class="nf">loadModel</span> = <span class="kr">do</span>
4848
popular <- get <span class="s">"/products/popular"</span>
4949
products <- runPar $ for_ popular \product -> <span class="kt">Par</span> (get product.uri)
50-
return $ <span class="kt">Model</span> products</pre>
50+
pure (<span class="kt">Model</span> products)</pre>
5151
</div>
5252
<div class="example">
5353
<h4>Generative Testing</h4>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "purescript-site",
33
"private": true,
44
"scripts": {
5-
"sass": "echo try{require('fs').mkdirSync('css');}catch(e){}; require('fs').writeFileSync('css/style.css', require('node-sass').renderSync({ file: 'sass/style.scss', outputStyle: 'compressed' }).css); | node",
5+
"sass": "echo \"try{require('fs').mkdirSync('css');}catch(e){}; require('fs').writeFileSync('css/style.css', require('node-sass').renderSync({ file: 'sass/style.scss', outputStyle: 'compressed' }).css);\" | node",
66
"rebuild": "npm run sass && stack --stack-yaml stack.yaml exec site rebuild"
77
},
88
"dependencies": {

0 commit comments

Comments
 (0)