scala - Example of State monad in business application -


i looking simple example of state monad in business application.

i have found examples -- memoisation calculate fibonacci numbers , random numbers generation -- see example business domain (preferably in scala).

for example, can find examples of using option, either, list, reader, , writer monads:

  • option : entity (order, product, customer, whatever) not exist
  • either : failure
  • list : customer orders, order items, etc.
  • reader : read entity database
  • writer : write log

now looking similar state monad, i.e. stateful computation mutable state, understand it.

the typical application reach state need supply of values, random number generator or supply of unique identifiers.

another typical use case testing application interacts database. using state, can simulate in-memory database , check program manipulates database in expected way.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -