Add an extra class to Control.Applicative.Alternative

Edward Kmett ekmett at gmail.com
Thu May 1 14:05:30 UTC 2014


The most commonly used version of that type is

http://hackage.haskell.org/package/these-0.4.1/docs/Data-These.html

but that isn't in base.

-Edward


On Thu, May 1, 2014 at 8:49 AM, Tom Ellis <
tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:

> On Thu, May 01, 2014 at 01:19:50PM +0200, S D Swierstra wrote:
> > On 30 Apr 2014, at 15:50 , Edward Kmett <ekmett at gmail.com> wrote:
> >
> > > A few thoughts:
> > >
> > > * Splittable has been used as a name historically for splitting random
> number generators and the like, so the name conflict (especially from
> somewhere so prominent) would be unfortunate. That can of course be fixed
> by a simple bikeshedding exercise.
> > >
> > > * You should be able to implement this in one pass. e.g. f a -> Either
> a (f a) rather than as two combinators, but it isn't clear to me what the
> getNonPure branch can do other than return the original when the scan fails
> or some partially zonked/expanded version of it.
> >
> > 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
>
> If (Nothing, Nothing) is impossible why not encode it in the type?
>
>     data OneOrBoth a b = One a | Other b | Both a b
>
>     class Splittable f where
>         split :: f a -> OneOrBoth (f a) a
>
> Tom
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140501/3397807e/attachment.html>


More information about the Libraries mailing list