Re: [Haskell-cafe] Missing join and split

2008-01-01 Thread Martin Sulzmann
Josef Svenningsson writes: > On Dec 28, 2007 11:40 PM, Mitar <[EMAIL PROTECTED]> wrote: > > Would not it be interesting and useful (but not really efficient) to > > have patterns something like: > > > > foo :: Eq a => a -> ... > > foo (_{4}'b') = ... > > > > which would match a list with fo

Re: [Haskell-cafe] Missing join and split

2008-01-01 Thread Josef Svenningsson
On Dec 28, 2007 11:40 PM, Mitar <[EMAIL PROTECTED]> wrote: > Would not it be interesting and useful (but not really efficient) to > have patterns something like: > > foo :: Eq a => a -> ... > foo (_{4}'b') = ... > > which would match a list with four elements ending with an element 'b'. Or: > > foo

Re: [Haskell-cafe] Missing join and split

2007-12-30 Thread Evan Laforge
> > Parser combinators basically provide generalized regexes, and they all > > take lists of arbitrary tokens rather than just Chars. I've written a > > simple combinator library before that dispenses with all the monadic > > goodness in favor of a group combinator and returning [Either [tok] > >

Re: [Haskell-cafe] Missing join and split

2007-12-30 Thread Sterling Clover
So a simple thing occured to me today. Rather than worry about the correct behavior for a join/split pair, we should just add unintercalate to the library. A bit verbose as a name, but at least there's no ambiguity. --s On Dec 29, 2007, at 2:18 PM, David Roundy wrote: On Fri, Dec 28, 200

Re: [Haskell-cafe] Missing join and split

2007-12-29 Thread David Roundy
On Fri, Dec 28, 2007 at 04:24:38PM +0100, Benja Fallenstein wrote: > On Dec 28, 2007 3:55 PM, David Roundy <[EMAIL PROTECTED]> wrote: > > On Dec 28, 2007 9:51 AM, Benja Fallenstein <[EMAIL PROTECTED]> wrote: > > > If you use intercalate to join, I would presume that you would want to > > > use an i

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Mitar
Hi! On Dec 29, 2007 12:13 AM, Evan Laforge <[EMAIL PROTECTED]> wrote: > Maybe you could use view patterns? > > foo (regex "(.*);(.*);(.*)") -> [c1, c2, c3] = ... Oh. Beautiful. :-) > Parser combinators basically provide generalized regexes, and they all > take lists of arbitrary tokens rather th

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Evan Laforge
> Would not it be interesting and useful (but not really efficient) to > have patterns something like: > > foo :: Eq a => a -> ... > foo (_{4}'b') = ... > > which would match a list with four elements ending with an element 'b'. Or: > > foo (_+';'_+';'_) = ... Maybe you could use view patterns? f

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Stefan O'Rear
On Fri, Dec 28, 2007 at 11:40:24PM +0100, Mitar wrote: > Hi! > > On Dec 28, 2007 5:51 PM, Lihn, Steve <[EMAIL PROTECTED]> wrote: > > Since regex is involved, it is specific to (Byte)String, not a generic > > list. > > Oh, this gives me an interesting idea: making regular expressions more > gener

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Mitar
Hi! On Dec 28, 2007 5:51 PM, Lihn, Steve <[EMAIL PROTECTED]> wrote: > Since regex is involved, it is specific to (Byte)String, not a generic > list. Oh, this gives me an interesting idea: making regular expressions more generic. Would not it be interesting and useful (but not really efficient) t

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Albert Y. C. Lai
Mitar wrote: I am really missing the (general) split function built in standard Haskell. I do not understand why there is something so specific as words and lines but not a simple split? The same goes for join. Don't forget Text.Regex.splitRegex. ___

RE: [Haskell-cafe] Missing join and split

2007-12-28 Thread Lihn, Steve
Programmer with perl background would think split like: = split Since regex is involved, it is specific to (Byte)String, not a generic list. Also it appears one would need help from Text.Regex(.PCRE) to do that. > intercalate a (split a xs) = a This identity rule does not hold for perl's

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Benja Fallenstein
On Dec 28, 2007 4:24 PM, Benja Fallenstein <[EMAIL PROTECTED]> wrote: > Right; I misspoke. What I meant was that you would want a split such that > > intercalate a (split a xs) = a > > for finite, total (a,xs) (and, since it's achievable, even for > infinite xs). Of course, (split a xs = [xs])

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Benja Fallenstein
On Dec 28, 2007 3:55 PM, David Roundy <[EMAIL PROTECTED]> wrote: > On Dec 28, 2007 9:51 AM, Benja Fallenstein <[EMAIL PROTECTED]> wrote: > > If you use intercalate to join, I would presume that you would want to > > use an inverse of it to split. I'd write it like this: > > Of course, there is no i

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread David Roundy
On Dec 28, 2007 9:51 AM, Benja Fallenstein <[EMAIL PROTECTED]> wrote: > If you use intercalate to join, I would presume that you would want to > use an inverse of it to split. I'd write it like this: But alas, words and lines differ on how properly to split, so there's no hint from the standard li

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Benja Fallenstein
Hi all, On Dec 28, 2007 12:38 PM, Andrew Coppin <[EMAIL PROTECTED]> wrote: > For joining you probably want some combination of intersperse and > concat, e.g. > > unlines = concat . intersperse "\n" And that's what we have :-) Data.List.intercalate :: [a] -> [[a]] -> [a] Data.List.intercalate x

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Andrew Coppin
Mitar wrote: Hi! I am really missing the (general) split function built in standard Haskell. I do not understand why there is something so specific as words and lines but not a simple split? The same goes for join. Yes, I can of course define them but ... in an interactive mode it would be quit