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
Post a Comment