title: `bind`/`flatMap`/`>>=` over Optional in Dhall
body: <p>I needed to <code>bind</code>/<code>flatMap</code>/<code>&gt;&gt;=</code> over an <code>Optional</code> in Dhall.</p>
  <p>I could not find an implementation for it and came up with my own.</p>
  <pre><code>let bindOptional
      : ∀(a : Type) → ∀(b : Type) → (a → Optional b) → Optional a → Optional b
      = λ(a : Type) →
        λ(b : Type) →
        λ(f : a → Optional b) →
        λ(o : Optional a) →
          Prelude.Optional.fold a o (Optional b) f (None b)
  </code></pre>
  <p>which I then use as follows</p>
  <pre><code>bindOptional Outer Inner (λ(x : Outer) → x.inner) outer
  </code></pre>
  <p>Is there really no such function defined in the <code>Prelude</code>? I assume I may have missed it.</p>
  <p>Furthermore:</p>
  <ol>
  <li><p>is there a more idiomatic way of defining it?</p>
  </li>
  <li><p>is it somehow possible to leverage type inference and make the call shorter? Something like</p>
  <pre><code>bindOptional _.inner outer -- the compiler infers `Outer` from `outer` and `Inner` from `_.inner`  
  </code></pre>
  </li>
  </ol>
  <p>I attempted to not give the type parameters but it doesn't seem possible (from my limited knowledge of the language).</p>