Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

associative law for monads is confusing due to Syntax enrichment (OO syntax) #125

Open
phderome opened this issue Jan 14, 2018 · 0 comments

Comments

@phderome
Copy link
Contributor

phderome commented Jan 14, 2018

Associativity is about 3 variables being composed twice where order of binary operation is not important e.g. a*(b*c) = (a*b)*c

Here we see only two variables in the discussion:
Page 98:
“Associativity: flatMapping over two functions f and g is the same as flatMapping over f and then flatMapping over g:

m.flatMap(f).flatMap(g) == m.flatMap(x => f(x).flatMap(g))

Had we used FP syntax Monad[_].flatMap(f) instead (with no m), we would see more explicitly and naturally three identifiers f, g, and h (not sure of final correct wording) operating twice on operator flatMap. Algebraic laws in the math world have no concern for the OO syntax, which is a programming construct, hence I think it's more natural to introduce 3 identifiers f, g, and h here instead of m, f, and g.

Perhaps it would make sense to state this law using the two distinct notations?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant