Giter Club home page Giter Club logo

java_monads's Introduction

Build Status tag Coverage Status Javadoc

Common Monads for Java

Monad

There is a great article here that talks about 3 very common and useful monads: Reader, Writer and State.

Reader

The Reader monad allows a common context (ie. DAO object) to be threaded through to chained functions. A common use for this type of monad is dependency injection.

http://eed3si9n.com/learning-scalaz/Reader.html
http://blog.originate.com/blog/2013/10/21/reader-monad-for-dependency-injection/

Writer

The Writer monad is used to keep a running log of chained computations. For instance, if you have multiple arithmetic functions chained together, the writer class can append to the log each time a computation is run, and the final result will contain both the final value of the computations, as well as the complete log.

http://eed3si9n.com/learning-scalaz/Writer.html
http://www.lispplusplus.com/2011/10/scala-writer-monad.html
http://blog.tmorris.net/posts/the-writer-monad-using-scala-example/

State

The State monad can be seen as similar to the reader monad, except that the state can be modified throughout the call chain, whereas the reader's context can only be read.

http://eed3si9n.com/learning-scalaz/State.html
https://softwarecorner.wordpress.com/2013/08/29/scalaz-state-monad/

java_monads's People

Contributors

enelson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.