title: Natural Transformations From Reader Bool To Maybe
body: <p>I'm reading Bartosz's awesome blog, and following along on challenge question 3, I'm a bit stumped:</p>
  
  <p><a href="https://bartoszmilewski.com/2015/04/07/natural-transformations/">https://bartoszmilewski.com/2015/04/07/natural-transformations/</a></p>
  
  <p><em>Q3: define some natural transformations from <code>Reader Bool</code> to <code>Maybe</code></em></p>
  
  <p>I have defined the Reader functor as: </p>
  
  <pre><code>newtype Reader e a = Reader (e-&gt;a)
  
  runReader :: Reader e a -&gt; e -&gt; a
  runReader (Reader f) env = f env
  
  instance Functor (Reader e) where
      fmap f (Reader g) = Reader (\x -&gt; f (g x))
  </code></pre>
  
  <p>and I want to find a natural transformation</p>
  
  <pre><code>n :: Reader Bool a -&gt; Maybe a
  </code></pre>
  
  <p>My intuition is that if <code>Reader</code>'s environment is <code>True</code>, I can have a <code>Just a</code>, and if <code>False</code>, then the natural transformation projects to <code>Nothing</code>. But that feels slightly monadic, or like a <code>Maybe</code> nested inside a <code>Reader</code>, like <code>Reader Bool (Maybe Int)</code>, so I'm not sure.</p>
  
  <p>I can't concieve of how to do that. The best I have is:</p>
  
  <pre><code>n :: Reader Bool a -&gt; Maybe a
  n (Reader f) = Just (f True)
  </code></pre>
  
  <p>But this cannot take into account the environment, nor return <code>Nothing</code>.</p>
  
  <p>I want to build a structure that commutes, building a square out of <code>fmap</code>, and natural transformations.</p>
  
  <p>For ex:</p>
  
  <pre><code>                          nat
  Reader Bool Int +---------------------------&gt; Maybe Int
       +                                            +
       |                                            |
       |                                            |
       |                                            |
       |    fmap show                               |  fmap show
       |                                            |
       |                                            |
       |                                            |
       |                                            |
       v                  nat                       v
  Reader Bool String  +--------------------------&gt; Maybe String                         
  </code></pre>
  
  <p>can you help me fill in the gaps?</p>