Skip to content

Commit

Permalink
deploy: 4e976f9
Browse files Browse the repository at this point in the history
  • Loading branch information
danicheg committed Aug 26, 2024
1 parent 06d29ca commit 5b228b3
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@17a242b8</span></code></pre>
</span><span class="comment">// eval: Eval[UserUpdateResult] = cats.Later@30bc485b</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$11634/0x00007fc13ffd2908@128c0bb2,
// f = cats.data.ContT$$Lambda$14346/0x00007f8030665158@1e6394fd,
// 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@3918cda0
</span><span class="comment">// anotherEval: Eval[UserUpdateResult] = cats.Eval$$anon$5@387fbe04
</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$11634/0x00007fc13ffd2908@22c5045b,
// f = cats.data.ContT$$Lambda$14346/0x00007f8030665158@17998bd3,
// 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$11638/0x00007fc13ffd3290@719b293a,
// f = cats.data.ContT$$Lambda$14350/0x00007f8030665ae0@c632f45,
// 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@2051fca2
</span><span class="comment">// eval: Eval[UserUpdateResult] = cats.Eval$$anon$5@7838d37d
</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@263853e
</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@76ecda75
</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$11796/0x00007fc13fd3a880@5c6f5d91
</span><span class="comment">// validator: FromString[Boolean] = cats.instances.Function1Instances$$anon$7$$Lambda$14508/0x00007f80306e71d0@7547705c
</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@31004a3
</span><span class="comment">// state: TeletypeState[Unit] = cats.data.IndexedStateT@2b351dd3
</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$11635/0x00007fc13ffbcd68@2cb5e62d
// f0 = scala.Function1$$Lambda$14347/0x00007f8030606ee0@72e5437f
// )
</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@78e9f426</span></code></pre>
</span><span class="comment">// valid: IndexedStateT[Eval, Closed.type, Open.type, Unit] = cats.data.IndexedStateT@5639b023</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@45bdc9de</span></code></pre>
</span><span class="comment">// res6: Eval[(Open.type, Unit)] = cats.Eval$$anon$1@13adbdd1</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@1ae1c791
</span><span class="comment">// right: Eval[String] = cats.Eval$$anon$1@23b7e4e
</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@35346cd2
</span><span class="comment">// reversedRight: Eval[String] = cats.Eval$$anon$1@1ab3d73a
</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 = 1724661263L)</span></code></pre>
</span><span class="comment">// res0: Either[DomainError, Long] = Right(value = 1724662164L)</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@46ba1853</span></code></pre>
</span><span class="comment">// nelBimonad: Bimonad[NonEmptyList] = repl.MdocSession$MdocApp$$anon$1@618c5ad8</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 5b228b3

Please sign in to comment.