Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Make Effect & EffectMapping a monoid structure #20

Merged
merged 2 commits into from
Oct 26, 2019

Conversation

inamiy
Copy link
Owner

@inamiy inamiy commented Oct 25, 2019

This PR adds Effect, Mapping, and EffectMapping conforming to Monoid structure (2 instances are combine-able with associativity and has identity) for better composition.

Please note that EffectMapping will now have multiple ways of conforming to Monoid since its internal structure is Input -> State -> (State, Effect)? returning Optional as the architectural choice.

Because of this, static func reduce will now introduce enum ReduceStrategy { case first, all, tryAll } for various reducing strategies.

(Previously, this reducing strategy was assumed to have .first only (picking one of the mapping from array), but this prevents from sibling mappings composition, so having .all is essentially needed to behave just as same behavior as Input -> State -> (State, Effect) which returns Identity(Monad) .

@inamiy inamiy added the enhancement New feature or request label Oct 25, 2019
@inamiy inamiy merged commit 34d8b98 into master Oct 26, 2019
@inamiy inamiy deleted the effect-and-mapping-as-monoid branch October 26, 2019 01:31
inamiy added a commit that referenced this pull request Jan 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant