class MonadPlus m => MonadLogic m whereSource
Would this then be equivalent to the following?
On 01 May 2014, at 13:19, S D Swierstra <doaitse@swierstra.net> wrote:
> I have probably not been clear enough. The relationship that should hold between getPure and getNonPure is as follows:
>
> case (getPure p, genNonPure p) of
> (Nothing, Nothing) -> "should not happen since p should have at least a pure or a nonpure part"
> (Just pp, Just npp) -> pure pp <|> npp
> (Just np, Nothing) -> pure np
> (Nothing, Just npp) -> npp
>
> is equivalent to p.
>
>
> I do not see how this would correspond to your use of Either?
>
> Doaitse
class Alternative f => Splittable f where
split :: f a -> (Maybe a, f a)
isEmpty :: f a -> Bool
isEmpty = isNothing . fst . split
One then would have something like:
getPure = fst . split
getNonPure x = guard (not (isEmpty fa)) >> Just fa
where fa = snd (split x)
and the expected laws might be easier to state
Daniel
_______________________________________________
Libraries mailing list
Libraries@haskell.org
http://www.haskell.org/mailman/listinfo/libraries