Skip to content

How to Represent Functional Boolean #1173

Answered by louthy
tiksn asked this question in Q&A
Jan 13, 2023 · 3 comments · 2 replies
Discussion options

You must be logged in to vote

It's a very strange request. Monads are for chaining operations: they yield a value when they're able to continue. You could consider this to be like true (but true + a value). If the monad can yield a value it's a truth, if not it's a falsity (false and no value). That's OK, but in your example the only value that will ever be yielded is Unit (or a version of). What's the point in that? It has no value outside of chaining operations together. It will never yield a usable value from within the monad (other than true or false).

If you just want the chaining behaviour of monads use && with bool, it does exactly what you're asking for. It stops on false and continues on true. If all are true

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tiksn
Comment options

Comment options

You must be logged in to vote
1 reply
@tiksn
Comment options

Answer selected by tiksn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants