
At that point it is very close to but stronger than MonadLogic's msplit:
class MonadPlushttp://hackage.haskell.org/package/base-4.6.0.1/docs/Control-Monad.html#t:Mo...
m
=> MonadLogic m
whereSourcehttp://hackage.haskell.org/package/logict-0.6.0.2/docs/src/Control-Monad-Log...
msplit :: m a -> m
(Maybehttp://hackage.haskell.org/package/base-4.6.0.1/docs/Data-Maybe.html#t:Maybe
(a,
m a))
-Edward
On Thu, May 1, 2014 at 2:01 PM, Daniel Gorín
On 01 May 2014, at 13:19, S D Swierstra
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
Would this then be equivalent to the following?
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