Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>It really looks like the <a href="https://hackage.haskell.org/package/base-4.2.0.1/docs/Data-Maybe.html" rel="nofollow"><code>Maybe</code></a> Monad pattern from Haskell.</p> <p>You should read the following, Wikipedia <a href="http://en.wikipedia.org/wiki/Monad_%28functional_programming%29#Maybe_monad" rel="nofollow">Monad (functional programming)</a>:</p> <p>And read <a href="http://kerflyn.wordpress.com/2011/12/05/from-optional-to-monad-with-guava/" rel="nofollow">From Optional to Monad with Guava</a> on <a href="http://kerflyn.wordpress.com/" rel="nofollow">Kerflyn's Blog,</a> which discusses about the Optional of Guava used as a Monad:</p> <hr> <p><strong>Edit:</strong> With Java8, there's a built-in Optional that has monadic operators like <code>flatMap</code>. This has been a controversial subject but finally has been implemented.</p> <p>See <a href="http://www.nurkiewicz.com/2013/08/optional-in-java-8-cheat-sheet.html" rel="nofollow">http://www.nurkiewicz.com/2013/08/optional-in-java-8-cheat-sheet.html</a></p> <pre><code>public Optional&lt;String&gt; tryFindSimilar(String s) //... Optional&lt;Optional&lt;String&gt;&gt; bad = opt.map(this::tryFindSimilar); Optional&lt;String&gt; similar = opt.flatMap(this::tryFindSimilar); </code></pre> <p>The <code>flatMap</code> operator is essential to allow monadic operations, and permits to easily chain calls that all return Optional results.</p> <p>Think about it, if you used the <code>map</code> operator 5 times you would end up with an <code>Optional&lt;Optional&lt;Optional&lt;Optional&lt;Optional&lt;String&gt;&gt;&gt;&gt;&gt;</code>, while using <code>flatMap</code> would give you <code>Optional&lt;String&gt;</code></p> <p>Since Java8 I would rather not use Guava's Optional which is less powerful.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload