Pattern combinator (#1105)

*  init

*  add pattern
This commit is contained in:
Boris
2019-11-26 06:03:04 +00:00
committed by Ilkka Seppälä
parent a9c3df78ee
commit 05e582ca3e
9 changed files with 556 additions and 27 deletions

33
combinator/README.md Normal file
View File

@@ -0,0 +1,33 @@
---
layout: pattern
title: Combinator
folder: combinator
permalink: /patterns/combinator/
categories: Behavioral
tags:
- Functional
- Reactive
- Idiom
---
## Also known as
Composition pattern
## Intent
The functional pattern representing a style of organizing libraries centered around the idea of combining functions.
Putting it simply, there is some type T, some functions for constructing "primitive" values of type T,
and some "combinators" which can combine values of type T in various ways to build up more complex values of type T.
## Applicability
Use the combinator pattern when:
- You are able to create a more complex value from more plain values but having the same type(a combination of them)
## Real world examples
- java.util.function.Function#compose
- java.util.function.Function#andThen
## Credits
- [Example for java](https://gtrefs.github.io/code/combinator-pattern/)
- [Combinator pattern](https://wiki.haskell.org/Combinator_pattern)
- [Combinatory logic](https://wiki.haskell.org/Combinatory_logic)