Haskell Foldable Wats

David Feuer david.feuer at gmail.com
Wed Feb 24 22:43:16 UTC 2016

Haskell's notion of Functor is in fact somewhat arbitrary from the
standpoint of mathematical functors. It's not at all arbitrary from the
standpoint of the general variety of type system Haskell uses. I'd call it
a "deep design choice" rather than a "technical limitation". I think the
newtype I gave for Flip and the type family I gave for FlipF are the best
you're ever likely to see. I do hope that the status of type families will
improve somewhat in the future (e.g., I'd love to be able to map a type
family over a list of types), but that won't get you the sorts of instances
you're dreaming of.

On Wed, Feb 24, 2016 at 4:56 PM, Kosyrev Serge <_deepfire at feelingofgreen.ru>

> David Feuer <david.feuer at gmail.com> writes:
> > On Wed, Feb 24, 2016 at 11:22 AM, Kosyrev Serge <_
> deepfire at feelingofgreen.ru> wrote:
> > > Are you also saying that this cannot be resolved by some kind of a
> > > type families-based type-level 'flip'?
> >
> > It really can't, no. You can define
> >
> > type family FlipF f a b where
> > FlipF f a b = f b a
> >
> > but FlipF, being a type family, is not first-class. You can't make any
> > instances whatsoever for FlipF f a -- you'll probably get an error
> > about a partially applied type family. What you *can* do is make a
> > Flip newtype:
> >
> > newtype Flip f a b = Flip {unflip :: f b a}
> How wrong would it be to say that the conceptually arbitrary choice of
> the Functor instance is "saved" by a technical limitation, making it the
> only choice?
> How likely is a proper type-level 'flip' tomorrow -- for some value of
> "proper" and "tomorrow"?
> --
> с уважениeм / respectfully,
> Косырев Сергей
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/libraries/attachments/20160224/f0aaa905/attachment-0001.html>

More information about the Libraries mailing list