Hello Holger,
Can you define an associative operation
orElse :: CMaybe r a -> CMaybe r a -> CMaybe r a
with identity `mzero` that satisfies the cancellation law?
No, because that function would need to cancel values of type a, but
the arguments of type (CMaybe r a) can only compute values of type r.
I'm afraid, I don't understand.
But you can define
orElse :: CMaybe a a -> CMaybe a a -> CMaybe r a
CMaybe ca `orElse` CMaybe cb = CMaybe (\k -> (ca return `mplus` cb
return) >>= k)
Good point.
But with this restricted type `orElse` is less useful. For example,
one cannot compute
fromCMaybe ((return False `orElse` return True) >>= guard)
because there, the arguments of `orElse` are of type `CMaybe () Bool`.
Cheers,
Sebastian
P.S.
> fromCMaybe :: CMaybe a a -> Maybe a
> fromCMaybe (CMaybe ca) = ca Just
--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe