[Haskell-cafe] Work on Collections Processing Arrows?
Adam Megacz
megacz at cs.berkeley.edu
Sat May 14 01:16:28 CEST 2011
David Barbour <dmbarbour at gmail.com> writes:
> I wonder if I need something like your use of 'representation' types, i.e.
> to restrict what sort of elements can be stored in a collection.
> ...
> I'll admit to some reluctance, however, to clutter up several typeclasses
> with four more types. What are your thoughts regarding this issue?
Yes, they certainly do clutter things up... but really, the whole
representation business is in there mostly to show that the "functor is
identity-on-objects" requirement of Freyd categories need not apply to
generalized arrows.
If you want to reduce the clutter, the simple trick I'm experimenting
with now works like this: start with your multi-parameter class
class GArrow g (**) u where ...
Then, for all but the first type argument, create a type family indexed
by the first type argument:
type family GArrowTensor g :: * -> * -> * -- (**)
type family GArrowUnit g :: * -- u
And then use -XFlexibleContexts to declare a wrapper class with only one
argument:
class (GArrow g (GArrowTensor g) (GArrowUnit g),
GArrowCopy g (GArrowTensor g) (GArrowUnit g),
GArrowSwap g (GArrowTensor g) (GArrowUnit g),
...
) => GArrowWrappedUp g
I'm sure you could do something similar with the type parameters "c" and
"r". The only price is that you can then have only one instance in
scope at any given point in time.
- a
More information about the Haskell-Cafe
mailing list