[Haskell-cafe] Efficiency Question

Daniel Fischer daniel.is.fischer at web.de
Sat Jan 15 05:28:18 EST 2005


Am Samstag, 15. Januar 2005 10:05 schrieben Sie:
> Hi Daniel,
>
> On Fri, 14 Jan 2005 21:57:25 +0100, Daniel Fischer
> <daniel.is.fischer at web.de> wrote:
>
> <snip>
>
> > Finally, in several contexts I needed to cons an element to one of a pair
> > of lists, so I defined
> >
> > infixr 5 &,§
>                ^^^
> Please be aware that you won't find this paragraph symbol on a uk or us
> keyboard. AFAIK it is just on the german one.
>
> > (&) :: a -> ([a],[b]) -> ([a],[b])
> > x & (xs,ys) = (x:xs,ys)
> >
> > (§) :: b -> ([a],[b]) -> ([a],[b])
> > y § (xs,ys) = (xs,y:ys).
> >
> > I find them useful (though I don't like the symbols, if you have any
> > better ideas, thx) and for splitAt, (&) saves another reduction per step.
>
> I think these operators should be more related to ":" like ":&" "&:" or
Yes, but as Stefan Holdermans already wrote, (:&) is illegal (operatornames 
beginning with ':' are infix Constructors). Since I use these operators 
mostly infix (up to now exclusively), I don't really want to type `consfst` 
all the time, hence I would need some stronger argument to convice me of 
using function names (after all, readability is to a large extent a matter of 
familiarity, you couldn't immediately understand ':', '+' ... either if you 
weren't thoroughly familiar with them).

A stronger relation to ':' is absolutely desirable, maybe
something like \: and /: would be better.

Cheers,
Daniel



More information about the Haskell-Cafe mailing list