Re: [Haskell-cafe] Why is there no splitSeperator function inData.List

2011-02-14 Thread Iustin Pop
On Sun, Feb 13, 2011 at 11:33:16PM -0800, Donn Cave wrote:
  It is curious though that the Python community managed to agree on a
  single implementation and include that in the standard library
 
 To me, it's more like 2 implementations, overloaded on the same
 function name.
 
 Python 2.6.2 (r262:71600, Aug 30 2009, 15:41:32) 
 [GCC 2.95.3-haiku-090629] on haiku1
 Type help, copyright, credits or license for more information.
  import string
  string.split(' ho ho ')
 ['ho', 'ho']
  string.split(' ho ho ', ' ')
 ['', 'ho', 'ho', '']
  
 
 I.e., let the separator parameter default (to whitespace), and you
 get what we have with Prelude.words, but specify a split character
 and you get a reversible split.  It wasn't a new idea, the Bourne
 shell for example has a similar dual semantics depending on whether
 the separator is white space or not.  Somehow doesn't seem right
 for Haskell, though.

Agreed, but I don't think that lacking a generic split functionality (as
in reversible split) is also good.

iustin

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why is there no splitSeperator function inData.List

2011-02-14 Thread Donn Cave
Quoth Peter Simons sim...@cryp.to,
...
 having a dictator is not a necessary prerequisite for the ability to
 make decisions. It's quite possible to decide controversial matters
 without a dictator -- say, by letting people vote.

The problem might be slightly miscast here, as an inability to reach
a decision in the face of controversy, and overall I don't think you
could make much of a case that Python's development is noticeably
more decisive.  If you really have 8 candidates for the semantics
of separator-split, then even if everyone can bring themselves to
agree on one, it's still just one, out of 8 missing functions, and
it's fairly understandable that this might not be very appealing.

Python also
  - is different in that function semantics can be conveniently overloaded
(I forgot the count parameter, I often want that one - split at the
first (n - 1) locations and leave the remainder intact)
  - is different as a general matter of style and niche
  - doesn't have our division between String and ByteString
  - makes it harder and more expensive to implement string.split()

Anyway, before it gets to the point where the crowds are camping in
the city square and demanding a vote, it might be interesting to see
where the code comes down on the matter, so I looked at the hackage
source I already happen to have at hand, a measly 252 Haskell source
files.

I found one (1) separator-split implementation.  I was surprised
at so few, as I've done it myself several times, so maybe I happen
to have an unrepresentative sample?

Donn

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] Why is there no splitSeperator function inData.List

2011-02-13 Thread Donn Cave
 It is curious though that the Python community managed to agree on a
 single implementation and include that in the standard library

To me, it's more like 2 implementations, overloaded on the same
function name.

Python 2.6.2 (r262:71600, Aug 30 2009, 15:41:32) 
[GCC 2.95.3-haiku-090629] on haiku1
Type help, copyright, credits or license for more information.
 import string
 string.split(' ho ho ')
['ho', 'ho']
 string.split(' ho ho ', ' ')
['', 'ho', 'ho', '']
 

I.e., let the separator parameter default (to whitespace), and you
get what we have with Prelude.words, but specify a split character
and you get a reversible split.  It wasn't a new idea, the Bourne
shell for example has a similar dual semantics depending on whether
the separator is white space or not.  Somehow doesn't seem right
for Haskell, though.

Donn Cave

___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe