[Haskell-cafe] ANN: monad-bool 0.1
John Wiegley
johnw at fpcomplete.com
Wed Jan 23 08:10:10 CET 2013
>>>>> John Wiegley <johnw at fpcomplete.com> writes:
> Never mind, when/unless + left work just fine for this.
You know, it's been a humorous day.
First ekmett showed that I can't make a sane Monad instance for AndM or OrM.
Then I discovered I can't make a reasonable Monoid (no mempty, given only
'toBool'), so I dropped down to a Semigroup. Further, my combinators for
EitherT can be implemented using just 'when' and 'left' to provide the
short-circuiting.
Already I had very little code left, until he showed me the Applicative
instance for Either, plus a little trick:
>>> Right 1 *> Right 2 *> Left 2 *> Right 5
Left 2 -- same functionality as my And semigroup
>>> let Left x |> y = y; x |> _ = x in Left 1 |> Right 2 |> Right 3
Right 2 -- same functionality as my Or semigroup
And poof, all my code just disappeared...
--
John Wiegley
FP Complete Haskell tools, training and consulting
http://fpcomplete.com johnw on #haskell/irc.freenode.net
More information about the Haskell-Cafe
mailing list