[Haskell-cafe] Different choice operations in a continuation monad
Sebastian Fischer
sebf at informatik.uni-kiel.de
Tue Jun 15 13:10:39 EDT 2010
On Jun 15, 2010, at 6:11 PM, Sebastian Fischer wrote:
>> 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`.
Silly me! It's not the type of the *arguments* which is `CMaybe ()
Bool` but the type of the *result* of `orElse`, which is perfectly
possible with your implementation!
The type may be general enough. Interesting twist!
I still don't understand why it is impossible to provide `orElse` with
the original type. I will think more about the reason you gave.
Sebastian
--
Underestimating the novelty of the future is a time-honored tradition.
(D.G.)
More information about the Haskell-Cafe
mailing list