<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Managing Dependencies on FsFlow</title>
    <link>https://adz.github.io/FsFlow/docs/managing-dependencies/</link>
    <description>Recent content in Managing Dependencies on FsFlow</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <atom:link href="https://adz.github.io/FsFlow/docs/managing-dependencies/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Environment Slicing</title>
      <link>https://adz.github.io/FsFlow/docs/managing-dependencies/env-slicing/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://adz.github.io/FsFlow/docs/managing-dependencies/env-slicing/</guid>
      <description>&lt;h1 id=&#34;environment-slicing-the-record-pattern&#34;&gt;Environment Slicing (The Record Pattern)&lt;/h1&gt;&#xA;&lt;p&gt;The Record Pattern is the most common way to manage dependencies in FsFlow. It uses standard F# records to define the &amp;ldquo;world&amp;rdquo; a workflow lives in.&lt;/p&gt;&#xA;&lt;h2 id=&#34;projecting-from-the-environment&#34;&gt;Projecting from the Environment&lt;/h2&gt;&#xA;&lt;p&gt;When a workflow needs a dependency, it &amp;ldquo;reads&amp;rdquo; it from the environment record.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-fsharp&#34; data-lang=&#34;fsharp&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;type&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;AppEnv&lt;/span&gt; &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt; &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;{&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;Gateway&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;IPingGateway&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#000&#34;&gt;Logger&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;:&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;ILogger&lt;/span&gt; &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;let&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;ping&lt;/span&gt; &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#000&#34;&gt;flow&lt;/span&gt; &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#8f5902;font-style:italic&#34;&gt;// &amp;#39;env&amp;#39; is the full AppEnv record&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;let!&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;gateway&lt;/span&gt; &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;Flow&lt;/span&gt;&lt;span style=&#34;color:#000;font-weight:bold&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;read&lt;/span&gt; &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;(&lt;/span&gt;&lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;fun&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;env&lt;/span&gt; &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;env&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;Gateway&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;        &lt;span style=&#34;color:#204a87;font-weight:bold&#34;&gt;return&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;!&lt;/span&gt; &lt;span style=&#34;color:#000&#34;&gt;gateway&lt;/span&gt;&lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;.&lt;/span&gt;&lt;span style=&#34;color:#000&#34;&gt;Ping&lt;/span&gt;&lt;span style=&#34;color:#3465a4&#34;&gt;()&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#ce5c00;font-weight:bold&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id=&#34;the-shorthand-_field&#34;&gt;The Shorthand: &lt;code&gt;_.Field&lt;/code&gt;&lt;/h3&gt;&#xA;&lt;p&gt;F# provides a nice shorthand for these simple projections. Instead of &lt;code&gt;(fun env -&amp;gt; env.Gateway)&lt;/code&gt;, you can write &lt;code&gt;_.Gateway&lt;/code&gt;. This makes the code much cleaner and easier to read.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Capabilities (CAPS)</title>
      <link>https://adz.github.io/FsFlow/docs/managing-dependencies/capabilities/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://adz.github.io/FsFlow/docs/managing-dependencies/capabilities/</guid>
      <description>&lt;h1 id=&#34;capabilities-caps&#34;&gt;Capabilities (CAPS)&lt;/h1&gt;&#xA;&lt;p&gt;The CAPS pattern lets you decouple your workflows from specific record types. Instead of saying &amp;ldquo;I need the &lt;code&gt;AppEnv&lt;/code&gt; record,&amp;rdquo; a workflow says &amp;ldquo;I need any environment that provides an &lt;code&gt;IClock&lt;/code&gt;.&amp;rdquo;&lt;/p&gt;&#xA;&lt;p&gt;This is achieved using the &lt;code&gt;Needs&amp;lt;&#39;dep&amp;gt;&lt;/code&gt; interface and the &lt;code&gt;Env&amp;lt;&#39;dep&amp;gt;&lt;/code&gt; request token.&lt;/p&gt;&#xA;&lt;h2 id=&#34;requesting-a-dependency-with-envdep&#34;&gt;Requesting a Dependency with &lt;code&gt;Env&amp;lt;&#39;dep&amp;gt;&lt;/code&gt;&lt;/h2&gt;&#xA;&lt;p&gt;In a CAPS workflow, you use the &lt;code&gt;Env&amp;lt;&#39;dep&amp;gt;&lt;/code&gt; token to request a dependency by its type. FsFlow handles finding that dependency in the environment for you.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
