Proposal: Add (&) to Data.Function
ekmett at gmail.com
Fri Nov 23 19:32:56 CET 2012
On Fri, Nov 23, 2012 at 6:34 AM, Heinrich Apfelmus <
apfelmus at quantentunnel.de> wrote:
> The (#) operator is quite natural and useful in the diagrams library,
> but the thing is that even though it is *implemented* as function
> application, it is *semantically* not a function application. It only
> serves to furnish shapes and diagrams with additional properties; it's type
> is very restricted, so to speak.
> Since the use cases mentioned (diagrams, lenses) are very similar, perhaps
> there is a general combinator (&) that does the job for both, but which has
> a much more restricted type and is not equivalent to reverse function
> application. Maybe an abstraction like "Settable functors",
> "Thingomorphisms with properties" or something like that.
In lens and in diagrams the type signature really does have to be a -> (a
-> b) -> b, because the type of the underlying object could (and often is)
changed. A critical part of lens is support for changing field types:
>>> ("Hello","Heinrich") & over both length
there it goes from (String,String) -> (Int,Int). There isn't any usable
commonality between the input and output type. Similarly in diagrams you
can use it to change it between R2 to R3, or otherwise enrich the target in
ways that change its type.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries