Skip to content

Commit

Permalink
deploy: 02bfdf7
Browse files Browse the repository at this point in the history
  • Loading branch information
danicheg committed Nov 16, 2024
1 parent 3f62d1b commit ddf4e53
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 35 deletions.
12 changes: 6 additions & 6 deletions datatypes/contt.html
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ <h1 id="contt" class="title">ContT</h1>
</span><span class="type-name">Succeeded</span><span>(</span><span class="identifier">user</span><span>.</span><span class="identifier">id</span><span>)
}
}
</span><span class="comment">// eval: Eval[UserUpdateResult] = cats.Later@800ded4</span></code></pre>
</span><span class="comment">// eval: Eval[UserUpdateResult] = cats.Later@68edb6dd</span></code></pre>
<p>Finally we can run the resulting <code>Eval</code> to actually execute the computation:</p>
<pre class="keep-together pdf epub"><code class="nohighlight"><span class="identifier">eval</span><span>.</span><span class="identifier">value</span><span>
</span><span class="comment">// Persisting updated user to the DB: User(100,Bob,150)
Expand All @@ -308,7 +308,7 @@ <h2 id="composition" class="section"><a class="anchor-link left" href="#composit
}
</span><span class="comment">// anotherComputation: ContT[Eval, UserUpdateResult, Map[String, String]] = FromFn(
// runAndThen = Single(
// f = cats.data.ContT$$Lambda$11837/0x00007f0bdeffe210@16d79f29,
// f = cats.data.ContT$$Lambda$14430/0x00007f6330685398@32a2b5ea,
// index = 0
// )
// )
Expand All @@ -319,7 +319,7 @@ <h2 id="composition" class="section"><a class="anchor-link left" href="#composit
</span><span class="type-name">Succeeded</span><span>(</span><span class="identifier">userFields</span><span>(</span><span class="string-literal">&quot;id&quot;</span><span>).</span><span class="identifier">toInt</span><span>)
}
}
</span><span class="comment">// anotherEval: Eval[UserUpdateResult] = cats.Eval$$anon$5@7298fc1
</span><span class="comment">// anotherEval: Eval[UserUpdateResult] = cats.Eval$$anon$5@6435b180
</span><span>
</span><span class="identifier">anotherEval</span><span>.</span><span class="identifier">value</span><span>
</span><span class="comment">// Persisting these fields to the DB: Map(id -&gt; 100, name -&gt; Bob, age -&gt; 150)
Expand All @@ -336,7 +336,7 @@ <h2 id="composition" class="section"><a class="anchor-link left" href="#composit
}
</span><span class="comment">// updateUserModel: ContT[Eval, UserUpdateResult, User] = FromFn(
// runAndThen = Single(
// f = cats.data.ContT$$Lambda$11837/0x00007f0bdeffe210@7eb39743,
// f = cats.data.ContT$$Lambda$14430/0x00007f6330685398@9a086f1,
// index = 0
// )
// )
Expand Down Expand Up @@ -370,7 +370,7 @@ <h2 id="composition" class="section"><a class="anchor-link left" href="#composit
</span><span class="identifier">updateUserModel</span><span> </span><span class="identifier">flatMap</span><span> </span><span class="identifier">persistToDb</span><span> </span><span class="identifier">flatMap</span><span> </span><span class="identifier">publishEvent</span><span>
</span><span class="comment">// chainOfContinuations: ContT[Eval, UserUpdateResult, UserUpdateResult] = FromFn(
// runAndThen = Single(
// f = cats.data.ContT$$Lambda$11841/0x00007f0bdeffeb98@2b3acb2,
// f = cats.data.ContT$$Lambda$14434/0x00007f6330685d20@6c75cdce,
// index = 0
// )
// )
Expand All @@ -381,7 +381,7 @@ <h2 id="composition" class="section"><a class="anchor-link left" href="#composit
</span><span class="identifier">finalResult</span><span>
}
}
</span><span class="comment">// eval: Eval[UserUpdateResult] = cats.Eval$$anon$5@7bb05b26
</span><span class="comment">// eval: Eval[UserUpdateResult] = cats.Eval$$anon$5@d9681f0
</span><span>
</span><span class="identifier">eval</span><span>.</span><span class="identifier">value</span><span>
</span><span class="comment">// Updated user model
Expand Down
4 changes: 2 additions & 2 deletions datatypes/eval.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ <h4 id="eval-later" class="section"><a class="anchor-link left" href="#eval-late
</span><span class="identifier">println</span><span>(</span><span class="string-literal">&quot;Running expensive calculation...&quot;</span><span>)
</span><span class="number-literal">1</span><span> + </span><span class="number-literal">2</span><span> * </span><span class="number-literal">3</span><span>
}
</span><span class="comment">// lazyEval: Eval[Int] = cats.Later@26df33cb
</span><span class="comment">// lazyEval: Eval[Int] = cats.Later@198aec11
</span><span>
</span><span class="identifier">lazyEval</span><span>.</span><span class="identifier">value</span><span>
</span><span class="comment">// Running expensive calculation...
Expand All @@ -276,7 +276,7 @@ <h4 id="eval-always" class="section"><a class="anchor-link left" href="#eval-alw
</span><span class="identifier">println</span><span>(</span><span class="string-literal">&quot;Running expensive calculation...&quot;</span><span>)
</span><span class="number-literal">1</span><span> + </span><span class="number-literal">2</span><span> * </span><span class="number-literal">3</span><span>
}
</span><span class="comment">// always: Eval[Int] = cats.Always@5274e805
</span><span class="comment">// always: Eval[Int] = cats.Always@6d1e4aaf
</span><span>
</span><span class="identifier">always</span><span>.</span><span class="identifier">value</span><span>
</span><span class="comment">// Running expensive calculation...
Expand Down
2 changes: 1 addition & 1 deletion datatypes/freeapplicative.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ <h2 id="example" class="section"><a class="anchor-link left" href="#example"><i
}
}</span></code></pre>
<pre class="keep-together pdf epub"><code class="nohighlight"><span class="keyword">val</span><span> </span><span class="identifier">validator</span><span> = </span><span class="identifier">prog</span><span>.</span><span class="identifier">foldMap</span><span>[</span><span class="type-name">FromString</span><span>](</span><span class="identifier">compiler</span><span>)
</span><span class="comment">// validator: FromString[Boolean] = cats.instances.Function1Instances$$anon$7$$Lambda$11999/0x00007f0bde5ac648@64d3d90c
</span><span class="comment">// validator: FromString[Boolean] = cats.instances.Function1Instances$$anon$7$$Lambda$14592/0x00007f6330747958@2ed270c6
</span><span class="identifier">validator</span><span>(</span><span class="string-literal">&quot;1234&quot;</span><span>)
</span><span class="comment">// res0: Boolean = false
</span><span class="identifier">validator</span><span>(</span><span class="string-literal">&quot;12345&quot;</span><span>)
Expand Down
4 changes: 2 additions & 2 deletions datatypes/freemonad.html
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ <h2 id="freet" class="section"><a class="anchor-link left" href="#freet"><i clas
</span><span class="keyword">import</span><span> </span><span class="type-name">TeletypeOps</span><span>.</span><span class="identifier">_</span><span>

</span><span class="keyword">val</span><span> </span><span class="identifier">state</span><span> = </span><span class="identifier">program</span><span>.</span><span class="identifier">foldMap</span><span>(</span><span class="identifier">interpreter</span><span>)
</span><span class="comment">// state: TeletypeState[Unit] = cats.data.IndexedStateT@40d9dba7
</span><span class="comment">// state: TeletypeState[Unit] = cats.data.IndexedStateT@654b3f57
</span><span class="keyword">val</span><span> </span><span class="identifier">initialState</span><span> = </span><span class="type-name">Nil</span><span>
</span><span class="comment">// initialState: Nil.type = List()
</span><span class="keyword">val</span><span> (</span><span class="identifier">stored</span><span>, </span><span class="identifier">_</span><span>) = </span><span class="identifier">state</span><span>.</span><span class="identifier">run</span><span>(</span><span class="identifier">initialState</span><span>).</span><span class="identifier">value</span><span>
Expand Down Expand Up @@ -789,7 +789,7 @@ <h2 id="freet" class="section"><a class="anchor-link left" href="#freet"><i clas
// value = Success(value = Some(value = Left(value = Action(value = 7))))
// )
// ),
// f0 = scala.Function1$$Lambda$11838/0x00007f0bdef9d3c0@b3edc3a
// f0 = scala.Function1$$Lambda$14431/0x00007f63306253c0@197f1fed
// )
</span><span class="keyword">val</span><span> </span><span class="identifier">evaluated</span><span> = </span><span class="identifier">hoisted</span><span>.</span><span class="identifier">foldMap</span><span>(</span><span class="identifier">tryInterpreter</span><span>)
</span><span class="comment">// evaluated: OptTry[Int] = OptionT(value = Success(value = Some(value = 12)))
Expand Down
4 changes: 2 additions & 2 deletions datatypes/state.html
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ <h2 id="changing-states" class="section"><a class="anchor-link left" href="#chan
</span><span class="identifier">_</span><span> &lt;- </span><span class="identifier">close</span><span>
</span><span class="identifier">_</span><span> &lt;- </span><span class="identifier">open</span><span>
} </span><span class="keyword">yield</span><span> ()
</span><span class="comment">// valid: IndexedStateT[Eval, Closed.type, Open.type, Unit] = cats.data.IndexedStateT@4ef11db</span></code></pre>
</span><span class="comment">// valid: IndexedStateT[Eval, Closed.type, Open.type, Unit] = cats.data.IndexedStateT@3ec27384</span></code></pre>
<p>Note that the inferred type of <code>valid</code> correctly models that this computation can be executed only with an initial <code>Closed</code> state.</p>
<pre class="keep-together pdf epub"><code class="nohighlight"><span class="identifier">valid</span><span>.</span><span class="identifier">run</span><span>(</span><span class="type-name">Open</span><span>)
</span><span class="comment">// error: type mismatch;
Expand All @@ -483,7 +483,7 @@ <h2 id="changing-states" class="section"><a class="anchor-link left" href="#chan
// valid.run(Open)
// ^^^^</span></code></pre>
<pre class="keep-together pdf epub"><code class="nohighlight"><span class="identifier">valid</span><span>.</span><span class="identifier">run</span><span>(</span><span class="type-name">Closed</span><span>)
</span><span class="comment">// res6: Eval[(Open.type, Unit)] = cats.Eval$$anon$1@30d3517e</span></code></pre>
</span><span class="comment">// res6: Eval[(Open.type, Unit)] = cats.Eval$$anon$1@3549b089</span></code></pre>


<hr class="footer-rule"/>
Expand Down
4 changes: 2 additions & 2 deletions typeclasses/bifoldable.html
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ <h2 id="tuple-as-bifoldable" class="section"><a class="anchor-link left" href="#
(</span><span class="identifier">s</span><span>, </span><span class="identifier">acc</span><span>) =&gt; </span><span class="identifier">acc</span><span>.</span><span class="identifier">map</span><span>(</span><span class="identifier">_</span><span> |+| </span><span class="identifier">s</span><span>),
(</span><span class="identifier">s</span><span>, </span><span class="identifier">acc</span><span>) =&gt; </span><span class="identifier">acc</span><span>.</span><span class="identifier">map</span><span>(</span><span class="identifier">_</span><span> |+| </span><span class="identifier">s</span><span>)
)
</span><span class="comment">// right: Eval[String] = cats.Eval$$anon$1@164686f
</span><span class="comment">// right: Eval[String] = cats.Eval$$anon$1@1e6233e8
</span><span>
</span><span class="identifier">left</span><span> === </span><span class="identifier">expected</span><span>
</span><span class="comment">// res2: Boolean = true
Expand All @@ -354,7 +354,7 @@ <h2 id="tuple-as-bifoldable" class="section"><a class="anchor-link left" href="#
(</span><span class="identifier">s</span><span>, </span><span class="identifier">acc</span><span>) =&gt; </span><span class="identifier">acc</span><span>.</span><span class="identifier">map</span><span>(</span><span class="identifier">_</span><span> |+| </span><span class="identifier">s</span><span>),
(</span><span class="identifier">s</span><span>, </span><span class="identifier">acc</span><span>) =&gt; </span><span class="identifier">acc</span><span>.</span><span class="identifier">map</span><span>(</span><span class="identifier">_</span><span> |+| </span><span class="identifier">s</span><span>)
)
</span><span class="comment">// reversedRight: Eval[String] = cats.Eval$$anon$1@706e0475
</span><span class="comment">// reversedRight: Eval[String] = cats.Eval$$anon$1@bd84e09
</span><span>
</span><span class="identifier">reversedRight</span><span>.</span><span class="identifier">value</span><span> === </span><span class="identifier">expected</span><span>
</span><span class="comment">// res4: Boolean = false</span></code></pre>
Expand Down
2 changes: 1 addition & 1 deletion typeclasses/bifunctor.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ <h2 id="either-as-a-bifunctor" class="section"><a class="anchor-link left" href=
</span><span class="identifier">error</span><span> =&gt; </span><span class="type-name">DomainError</span><span>(</span><span class="identifier">error</span><span>.</span><span class="identifier">getMessage</span><span>),
</span><span class="identifier">dateTime</span><span> =&gt; </span><span class="identifier">dateTime</span><span>.</span><span class="identifier">toEpochSecond</span><span>
)
</span><span class="comment">// res0: Either[DomainError, Long] = Right(value = 1731273899L)</span></code></pre>
</span><span class="comment">// res0: Either[DomainError, Long] = Right(value = 1731756269L)</span></code></pre>
<p><code>Bifunctor</code> also defines a convenience function called <code>leftMap</code>, which is defined as follows:</p>
<pre class="keep-together pdf epub"><code class="nohighlight"><span class="keyword">def</span><span> </span><span class="declaration-name">leftMap</span><span>[</span><span class="type-name">A</span><span>, </span><span class="type-name">B</span><span>, </span><span class="type-name">C</span><span>](</span><span class="identifier">fab</span><span>: </span><span class="type-name">F</span><span>[</span><span class="type-name">A</span><span>, </span><span class="type-name">B</span><span>])(</span><span class="identifier">f</span><span>: </span><span class="type-name">A</span><span> =&gt; </span><span class="type-name">C</span><span>): </span><span class="type-name">F</span><span>[</span><span class="type-name">C</span><span>, </span><span class="type-name">B</span><span>] = </span><span class="identifier">bimap</span><span>(</span><span class="identifier">fab</span><span>)(</span><span class="identifier">f</span><span>, </span><span class="identifier">identity</span><span>)</span></code></pre>
<p>There is no <code>rightMap</code> however - use <code>map</code> instead. The reasoning behind this is that in Cats, the instances of
Expand Down
2 changes: 1 addition & 1 deletion typeclasses/bimonad.html
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ <h3 id="nonemptylist-as-a-bimonad" class="section"><a class="anchor-link left" h
</span><span> </span><span class="keyword">override</span><span> </span><span class="keyword">def</span><span> </span><span class="declaration-name">tailRecM</span><span>[</span><span class="type-name">A</span><span>, </span><span class="type-name">B</span><span>](</span><span class="identifier">a</span><span>: </span><span class="type-name">A</span><span>)(</span><span class="identifier">fn</span><span>: </span><span class="type-name">A</span><span> =&gt; </span><span class="type-name">NonEmptyList</span><span>[</span><span class="type-name">Either</span><span>[</span><span class="type-name">A</span><span>, </span><span class="type-name">B</span><span>]]): </span><span class="type-name">NonEmptyList</span><span>[</span><span class="type-name">B</span><span>] =
???
}
</span><span class="comment">// nelBimonad: Bimonad[NonEmptyList] = repl.MdocSession$MdocApp$$anon$1@2104165e</span></code></pre>
</span><span class="comment">// nelBimonad: Bimonad[NonEmptyList] = repl.MdocSession$MdocApp$$anon$1@2672b8d6</span></code></pre>
<p>Note the equivalence:</p>
<pre class="keep-together pdf epub"><code class="nohighlight"><span class="identifier">nelBimonad</span><span>.</span><span class="identifier">pure</span><span>(</span><span class="boolean-literal">true</span><span>).</span><span class="identifier">extract</span><span> === </span><span class="type-name">NonEmptyList</span><span>.</span><span class="identifier">one</span><span>(</span><span class="boolean-literal">true</span><span>).</span><span class="identifier">head</span><span>
</span><span class="comment">// res0: Boolean = true</span></code></pre>
Expand Down
Loading

0 comments on commit ddf4e53

Please sign in to comment.