Brian Hulley wrote: > Jared Updike wrote: >>> [a,b,c ; tail] === a :: b :: c :: tail -- >>> where :: >> >> How is [a,b,c ; tail] simpler, clearer or less typing than >> a:b:c:tail ? I think that the commas and semicolons are easy to >> confuse. > > It seems strange that you can write [a,b,c] with a nice list sugar but > if you want to include a tail you have to switch to the infix notation > using list cons. Prolog for example allows you to write [a,b,c|Tail] but > neither Haskell nor ML allows this. In Haskell, | is used to introduce a > list comprehension so I was just trying to find a replacement symbol for > when you want the equivalent of the Prolog list sugar so that you > wouldn't be forced to use infix notation. > > All this was not to replace a:b:c:tail but was to replace a::b::c::tail > so that : could be used for type annotations instead. >
There is the .. operator which is unused in pattern matching contexts. So maybe case [1,3..] of [a,b,c,tail..] -> tail -- I like this one, the ..] catches the eye better [a,b,c,..tail] -> tail -- I think this is less clear at a glance [a,b,c,..tail..] -> tail -- I expect no one to like this [a,b,c,_..] -> [a,b,c] -- Not the best looking thing I've ever seen [a,b,c,.._] -> [a,b,c] -- ditto [a,b,c,.._..] -> [a,b,c] -- ick But this implies [a,b,c,[]..] is the same as [a,b,c] and [a,b,c,[d,e,f]..] is the same as [a,b,c,d,e,f] and [a,b,c,[d,e,f..]..] is [a,b,c,d,e,f..] Wacky. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe