[Haskell-cafe] arrow notation
Ross Paterson
ross at soi.city.ac.uk
Mon Feb 11 16:45:38 CET 2013
On Sun, Feb 10, 2013 at 09:28:12PM +0100, Petr Pudlák wrote:
> 2013/2/9 Conal Elliott <conal at conal.net> wrote:
> > What I have in mind is a small collection of methods including fst & snd
> > (and similarly for sums) that could be defined via arr but could instead
> > form the basis of translating restricted arrow notation for (pseudo-)arrows
> > that don't support arr.
>
> I also support this idea, I'd appreciate such a generalization.
>
> As an example, where it would be useful: One of my students was working on a
> (very nice) project where he used Haskell as a DSL for generating a FRP-like
> javascript code. The arrow notation without "arr" would be ideal for this
> situation. He couldn't implement "arr" as it would require to translate an
> arbitrary Haskell function to JS. So having a more general variant of "Arrow"
> without "arr" and with a collection of methods sufficient for the arrow
> notation would be quite helpful. (I wonder what methods would have to be
> included in the collection.)
Let's try to break this down. Suppose we split
arr :: forall b c. (b -> c) -> a b c
into two primitives
(^>>) :: forall b c d. (b -> c) -> a c d -> a b d
id :: forall b. a b b
The contravariant functor (^>>) is essential to arrow notation, but I
suspect the issue is the universally quantified b in the type of id (or
equivalently returnA). One might instead use a variant of id constrained
to an ADT with just the operations you want.
More information about the Haskell-Cafe
mailing list