[Haskell-cafe] Efficiency Question

Daniel Fischer daniel.is.fischer at web.de
Sat Jan 15 09:30:38 EST 2005


Am Samstag, 15. Januar 2005 14:36 schrieben Sie:

> Well, to start, the type signatures are unnecessarily restrictive.
Yep, but since I always needed them for taking elements that satisfied either 
of two predicates from a list, that was the type that first came to mind 
(actually the zero'th type used ([a],[a]) ).
> Then, the function that also is not in the Report, but does come up
> quite a bit by people who get into a point-free or categorical style is
> the bifunctor,
> (***) :: (a -> b) -> (c -> d) -> (a,c) -> (b,d)
> f *** g = \(a,b) -> (f a,g b)
> this is an instance of (***) in Control.Arrow, hence the name.

That's good to know, thanks.
>
> So, your first function is,
> (&) x = (x:) *** id
> or using another function from Control.Arrow,
> (&) x = first (x:)
>
> I can say that I have wanted (***), I can't say that I've ever wanted
> your two functions.  Also, first (x:) seems to be more self-documenting.

I haven't read Control.Arrow yet, but it seems at first glance that I should 
write
 first (x:) (xs,y)
second (y:) (x,ys)
instead?
That looks good to me, more to type, alas, but much better to read.
Many thanks,
Daniel



More information about the Haskell-Cafe mailing list