title: Haskell: Better way of writing Maybe Endo?
body: <p>I have just discovered the Endo type thanks to the <a href="https://hackage.haskell.org/package/network-api-support-0.1.0" rel="noreferrer">network-api-support</a> package and I have found the need to be able to throw Maybe values into Endo's. As a result I have written a function called maybeEndo. Here is an example of it being used:</p>
  
  <pre><code>setProxy :: Proxy -&gt; RequestTransformer
  setProxy (Proxy pHost pPort) = Endo $ addProxy pHost pPort
  
  maybeEndo :: (a -&gt; Endo b) -&gt; Maybe a -&gt; Endo b
  maybeEndo _ Nothing = Endo id
  maybeEndo f (Just v) = f v
  
  setPotentialProxy :: Maybe Proxy -&gt; RequestTransformer
  setPotentialProxy = maybeEndo setProxy
  </code></pre>
  
  <p>What strikes me is that this seems like something that should be encapsulated into some type of pattern already.</p>