Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-21 Thread Jon Fairbairn
On 2006-07-20 at 18:31BST I wrote: On 2006-07-13 at 10:16BST I wrote: Hooray! I've been waiting to ask Why aren't we asking what laws hold for these operations? Having thought about this for a bit, I've come up with the below. This is intended to give the general idea -- it's not

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-20 Thread Jon Fairbairn
On 2006-07-13 at 10:16BST I wrote: Hooray! I've been waiting to ask Why aren't we asking what laws hold for these operations? Having thought about this for a bit, I've come up with the below. This is intended to give the general idea -- it's not polished code, and I'm not at all wedded to the

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-13 Thread Jon Fairbairn
On 2006-07-12 at 23:24BST Brian Hulley wrote: Christian Maeder wrote: Donald Bruce Stewart schrieb: Question over whether it should be: splitBy (=='a') aabbaca == [,,bb,c,] or splitBy (=='a') aabbaca == [bb,c] I argue the second form is what people usually want. Yes,

[Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Simon Marlow
Evan Laforge wrote: splitBy :: (a - Bool) -- ^ whether element is a seperator - [a] -- ^ list to split - [[a]] P.S. inspecting more than one element looks like an over-generalization to me and should be left to parsers or regexp libs. It's more generally useful if you

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Donald Bruce Stewart
simonmarhaskell: I guess the problem with the splitWith thing is that it's a slippery path that leads right up to full-on parsers. Exactly, and this is why we didn't reach a concensus last time. Would someone like to make a concrete proposal (with code!) for 2-3 functions we could

RE: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Bayley, Alistair
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Donald Bruce Stewart I vote for this, currently implemented in Data.ByteString: -- | split on characters split:: Char - String - [String] -- | split on predicate * splitBy :: (Char -

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Christian Maeder
Donald Bruce Stewart schrieb: No parsers! I agree, I vote for this, currently implemented in Data.ByteString: from which package comes Data.ByteString? -- | split on characters split:: Char - String - [String] the type for lists should then be: split :: Eq a = a -- ^

Re[2]: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Bulat Ziganshin
Hello Donald, Wednesday, July 12, 2006, 12:55:50 PM, you wrote: Question over whether it should be: splitBy (=='a') aabbaca == [,,bb,c,] or splitBy (=='a') aabbaca == [bb,c] I argue the second form is what people usually want. 1) at least for 'lines' people prefer first 2)

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Donn Cave
On Wed, 12 Jul 2006, Donald Bruce Stewart wrote: I vote for this, currently implemented in Data.ByteString: -- | split on characters split:: Char - String - [String] -- | split on predicate * splitBy :: (Char - Bool) - String - [String] and --

[Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread tpledger
Jared Updike wrote: split is... unconcatIntersperse. How about separate? (split or splitBy is better but it is used all over the place in many libs) And for strings I definitely would use split :: [a] - [a] - [[a]] a lot, just like Python's split function. And words works great for

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Evan Laforge
2006/7/12, [EMAIL PROTECTED] [EMAIL PROTECTED]: Jared Updike wrote: split is... unconcatIntersperse. How about separate? (split or splitBy is better but it is used all over the place in many libs) And for strings I definitely would use split :: [a] - [a] - [[a]] a lot, just like

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Brian Hulley
Christian Maeder wrote: Donald Bruce Stewart schrieb: Question over whether it should be: splitBy (=='a') aabbaca == [,,bb,c,] or splitBy (=='a') aabbaca == [bb,c] I argue the second form is what people usually want. Yes, the second form is needed for words, but the first form is

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Donn Cave
On Wed, 12 Jul 2006, Evan Laforge wrote: Also, my version of the split but don't drop the delimiter is breakAll, since it's like a recursive break. words/unwords and lines/unlines have one argument, so a 2 argument fielts/unfields would break that convention. Maybe: fields = csv

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Jared Updike
fields = csv `separateWith` , csv = fields `joinWith` , -- equivalent to concatIntersperse Hence I would much rather have the split condition be the first parameter -- the infix notation looks good, but it will need a flip to get the parameters in the right order. This also goes along with

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-12 Thread Donn Cave
Quoth Jared Updike [EMAIL PROTECTED]: (... quoting me) | Hence I would much rather have the split condition be the first | parameter -- the infix notation looks good, but it will need a | flip to get the parameters in the right order. | | This also goes along with join in python, i.e. | |

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-11 Thread Donn Cave
Quoth John Meacham [EMAIL PROTECTED]: ... | just a note: I find splitBy a much nicer routine to provide. | | splitBy :: (a - Bool) -- ^ whether char is a separator | - [a] -- ^ list to split | - [[a]] Starting from the assumption that in most cases the list to be split will be

[Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-11 Thread Christian Maeder
John Meacham schrieb: just a note: I find splitBy a much nicer routine to provide. I would support this, if it helped to find a consensus. It's more difficult to decide if empty lists as elements of the result list (at the beginning, at the end or in the middle) should be returned. I would say

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-11 Thread Evan Laforge
splitBy :: (a - Bool) -- ^ whether element is a seperator - [a] -- ^ list to split - [[a]] P.S. inspecting more than one element looks like an over-generalization to me and should be left to parsers or regexp libs. It's more generally useful if you don't drop the separators

[Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-11 Thread Yitzchak Gale
I personally use split :: Eq a = [a] - [a] - [[a]] all the time, much more often than splitBy :: (a - Bool) - [a] - [[a]] But I don't call it split. By analogy with concatMap, the Haskell analogue of Perl/Python join is concatIntersperse. Then, by analogy with lines/unlines, the Haskell

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-11 Thread Jared Updike
split is... unconcatIntersperse. How about separate? (split or splitBy is better but it is used all over the place in many libs) And for strings I definitely would use split :: [a] - [a] - [[a]] a lot, just like Python's split function. And words works great for breaking on multiple spaces,

Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-10 Thread Bulat Ziganshin
Hello Donald, Monday, July 10, 2006, 11:48:48 AM, you wrote: Anyone rememeber what the result of the let's get split into the base library movement's work was? it will be even better to ask permission from John Goerzen and move to Data.List the whole stringlist beastiary from MissingH --

[Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-10 Thread Christian Maeder
Simon Marlow schrieb: Donald Bruce Stewart wrote: Hacking up your own custom split (or a tokens/splitOnGlue) must be one of the most common questions from beginners on the irc channel. Anyone rememeber what the result of the let's get split into the base library movement's work was?

[Haskell-cafe] Re: Why is there no splitBy in the list module?

2006-07-10 Thread John Meacham
On Mon, Jul 10, 2006 at 02:26:23PM +0200, Christian Maeder wrote: Our current (special) version is: {- | A function inspired by the perl function split. A list is splitted on a seperator element in smaller non-empty lists. The seperator element is dropped from the resulting list. -}