Skip to content

Latest commit

 

History

History
 
 

monad

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
layout title folder permalink pumlid categories tags
pattern
Monad
monad
/patterns/monad/
9SR13SCm20NGLPe1OkxTXjWeSMMm1Pza_LRgExsjMntP97syBc35cyZvAMV7bKU6U9q6CPGwbVh8Xy5E7xvvRnBzj7qn86v1ol4BwJHk9AZ_bNGjAtLy0G00
Other
Java
Difficulty-Expert
Functional

Intent

Monad pattern based on monad from linear algebra represents the way of chaining operations together step by step. Binding functions can be described as passing one's output to another's input basing on the 'same type' contract. Formally, monad consists of a type constructor M and two operations: bind - that takes monadic object and a function from plain object to monadic value and returns monadic value return - that takes plain type object and returns this object wrapped in a monadic value.

alt text

Applicability

Use the Monad in any of the following situations

  • when you want to chain operations easily
  • when you want to apply each function regardless of the result of any of them

Credits