Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread John Lato
Hi Alberto, To some extent this already exists, it's just that nobody uses it. I believe it's the approach taken by the Edison libraries. Also the ListLike package provides the type classes ListLike, StringLike, and a few others. Neither seems to have become very popular despite having

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Alberto G. Corona
Once we have a tree of type classes suitable for all containers, as you said, theoretically it shouldn't very difficult to incorporate the testing of different instances for each class used in a program, besides testing different compilation flags in a genetic algoritm. This latter has already

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Stephen Tetley
Hi Alberto I rather doubt a valuable set of type classes that is suitable for all containers exists, I'm afraid. If you consider containers as the containers package, the data structures are all (?) functorial - but they have different shapes, so e.g. a cons operation makes sense on the linear

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread John Lato
I still think that getting other authors to use it would be the biggest difficulty. Another concern of mine is that RULEs-based fusion can be fragile; if the type classes prevent fusion from occurring you'll never approach the performance of monomorphic code. That said, I think this is worth

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Michael Snoyman
I have a very specific StringLike typeclass in the web-encodings package so that I can- for example- to HTML entity encoding on String, (lazy) bytestrings and (lazy) text. Of course, I need to make assumptions about character encoding for the bytestring version. Michael On Wed, Mar 24, 2010 at

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Bryan O'Sullivan
On Wed, Mar 24, 2010 at 5:48 AM, Stephen Tetley stephen.tet...@gmail.comwrote: I rather doubt a valuable set of type classes that is suitable for all containers exists, I'm afraid. I don't think it's so clear cut. Stepanov's Elements of Programming lays out a pretty clear (and familiar to

Fwd: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Alberto G. Corona
-- Forwarded message -- From: Alberto G. Corona agocor...@gmail.com Date: 2010/3/24 Subject: Re: [Haskell-cafe] Bytestrings and [Char] To: Stephen Tetley stephen.tet...@gmail.com 2010/3/24 Stephen Tetley stephen.tet...@gmail.com Hi Alberto I rather doubt a valuable set

Fwd: [Haskell-cafe] Bytestrings and [Char]

2010-03-24 Thread Alberto G. Corona
2010/3/24 Stephen Tetley stephen.tet...@gmail.com If you consider containers as the containers package, the data structures are all (?) functorial - but they have different shapes, so e.g. a cons operation makes sense on the linear ones (Data.Sequence, Data.List) but not on Data.Map,

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Johann Höchtl
On 22.03.2010 14:10, Johan Tibell wrote: On Mon, Mar 22, 2010 at 1:16 PM, Johann Höchtljohann.hoec...@gmail.com wrote: My question or discussion point: Why not depreciate [Char] altogether and favour of lazy Bytestrings? A sequence of bytes is not the same thing as a sequence of Unicode

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Johann Höchtl
On 22.03.2010 14:15, Ivan Miljenovic wrote: On 23 March 2010 00:10, Johan Tibelljohan.tib...@gmail.com wrote: A sequence of bytes is not the same thing as a sequence of Unicode code points. If you want to replace String by something more efficient have a look at Data.Text. Though

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread John Millikin
On Tue, Mar 23, 2010 at 00:27, Johann Höchtl johann.hoec...@gmail.com wrote: How are ByteStrings (Lazy, UTF8) and Data.Text meant to co-exist? When I read bytestrings over a socket which happens to be UTF16-LE encoded and identify a fitting function in Data.Text, I guess I have to transcode

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Joachim Breitner
Hi, Am Dienstag, den 23.03.2010, 08:51 -0700 schrieb John Millikin: On Tue, Mar 23, 2010 at 00:27, Johann Höchtl johann.hoec...@gmail.com wrote: How are ByteStrings (Lazy, UTF8) and Data.Text meant to co-exist? When I read bytestrings over a socket which happens to be UTF16-LE encoded and

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Iustin Pop
On Tue, Mar 23, 2010 at 08:51:16AM -0700, John Millikin wrote: On Tue, Mar 23, 2010 at 00:27, Johann Höchtl johann.hoec...@gmail.com wrote: How are ByteStrings (Lazy, UTF8) and Data.Text meant to co-exist? When I read bytestrings over a socket which happens to be UTF16-LE encoded and

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Nick Bowler
On 18:11 Tue 23 Mar , Iustin Pop wrote: I agree with the principle of correctness, but let's be honest - it's (many) orders of magnitude between ByteString and String and Text, not just a few percentage points… I've been struggling with this problem too and it's not nice. Every time one

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Iustin Pop
On Tue, Mar 23, 2010 at 01:21:49PM -0400, Nick Bowler wrote: On 18:11 Tue 23 Mar , Iustin Pop wrote: I agree with the principle of correctness, but let's be honest - it's (many) orders of magnitude between ByteString and String and Text, not just a few percentage points… I've been

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Iustin Pop
On Tue, Mar 23, 2010 at 05:53:00PM +, Vincent Hanquez wrote: On 23/03/10 17:11, Iustin Pop wrote: Data.ByteString.Lazy (bytestring readFile + length) - 10 miliseconds, incorrect length (as expected). Data.ByteString.Lazy.UTF8 (system readFile + fromString + length) - 11 seconds,

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Bryan O'Sullivan
2010/3/23 Iustin Pop iu...@k1024.org I agree with the principle of correctness, but let's be honest - it's (many) orders of magnitude between ByteString and String and Text, not just a few percentage points… Well, your benchmarks are highly suspect. See below. Data.ByteString.Lazy.UTF8

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Thomas DuBuisson
BOS: Well, your benchmarks are highly suspect. Attached is another benchmark with similar results. This is no criterion benchmark but I did try to adjust a wee bit for cache issues. Suffice to say I am not yet impressed with Data.Text performance wise. In the broader scope I feel there is a

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Nick Bowler
On 18:25 Tue 23 Mar , Iustin Pop wrote: On Tue, Mar 23, 2010 at 01:21:49PM -0400, Nick Bowler wrote: On 18:11 Tue 23 Mar , Iustin Pop wrote: I agree with the principle of correctness, but let's be honest - it's (many) orders of magnitude between ByteString and String and Text, not

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Iustin Pop
On Tue, Mar 23, 2010 at 03:31:33PM -0400, Nick Bowler wrote: On 18:25 Tue 23 Mar , Iustin Pop wrote: On Tue, Mar 23, 2010 at 01:21:49PM -0400, Nick Bowler wrote: On 18:11 Tue 23 Mar , Iustin Pop wrote: I agree with the principle of correctness, but let's be honest - it's

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Iustin Pop
On Tue, Mar 23, 2010 at 11:22:23AM -0700, Bryan O'Sullivan wrote: 2010/3/23 Iustin Pop iu...@k1024.org I agree with the principle of correctness, but let's be honest - it's (many) orders of magnitude between ByteString and String and Text, not just a few percentage points… Well, your

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Johann Höchtl
Bryan O'Sullivan wrote: 2010/3/23 Iustin Pop iu...@k1024.org mailto:iu...@k1024.org I agree with the principle of correctness, but let's be honest - it's (many) orders of magnitude between ByteString and String and Text, not just a few percentage points… Well, your benchmarks

Fwd: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Alberto G. Corona
The question can be generalized via type classes: Is there any common set of primitives encapsulated into a single type class that has instances for Strings (Data.List) ByteStrings, Data.Text, Lazy bytestrings, Arrays, vectors and wathever container that can store an boxed, unboxed, packed

Fwd: [Haskell-cafe] Bytestrings and [Char]

2010-03-23 Thread Alberto G. Corona
Just a dream: -separate interface and implementation for all containers, via type classes -develop, by genetic programming techniques + quickcheck, a system that find the best container implementation for a particular program. Is that suitable for a Google Summer of Code project? 2010/3/23

[Haskell-cafe] Bytestrings and [Char]

2010-03-22 Thread Johann Höchtl
Hello, I was recentyl playing with Haskell (GHC that is) IO and text processing. Bytestrings and Lazy Bytestrings allow for fast and memory eficient string (well, bytestring) handling, yet a lot of libraries do not support them (yet) Given the incredibly inneficient memory representation of

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-22 Thread Ivan Lazar Miljenovic
Johann Höchtl johann.hoec...@gmail.com writes: Bytestrings and Lazy Bytestrings allow for fast and memory eficient string (well, bytestring) handling, yet a lot of libraries do not support them (yet) WHat do you mean? A lot of libraries need to use String because it's easier to deal with and

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-22 Thread Johan Tibell
On Mon, Mar 22, 2010 at 1:16 PM, Johann Höchtl johann.hoec...@gmail.com wrote: My question or discussion point: Why not depreciate [Char] altogether and favour of lazy Bytestrings? A sequence of bytes is not the same thing as a sequence of Unicode code points. If you want to replace String by

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-22 Thread Ivan Miljenovic
On 23 March 2010 00:10, Johan Tibell johan.tib...@gmail.com wrote: A sequence of bytes is not the same thing as a sequence of Unicode code points. If you want to replace String by something more efficient have a look at Data.Text. Though Data.Text still has the disadvantage of not being as

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-22 Thread David Leimbach
On Mon, Mar 22, 2010 at 6:10 AM, Johan Tibell johan.tib...@gmail.comwrote: On Mon, Mar 22, 2010 at 1:16 PM, Johann Höchtl johann.hoec...@gmail.com wrote: My question or discussion point: Why not depreciate [Char] altogether and favour of lazy Bytestrings? A sequence of bytes is not the

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-22 Thread Jochem Berndsen
David Leimbach wrote: On Mon, Mar 22, 2010 at 6:10 AM, Johan Tibell johan.tib...@gmail.com mailto:johan.tib...@gmail.com wrote: On Mon, Mar 22, 2010 at 1:16 PM, Johann Höchtl johann.hoec...@gmail.com mailto:johann.hoec...@gmail.com wrote: My question or discussion point: Why

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-22 Thread Lennart Augustsson
Turn on OverloadedStrings and you can pattern match on any type you like that is in the IsString class. Which means that Data.Text can use string literals just like regular strings (but you can't use Char literals in the match). On Mon, Mar 22, 2010 at 1:15 PM, Ivan Miljenovic

Re: [Haskell-cafe] Bytestrings and [Char]

2010-03-22 Thread Mads Lindstrøm
Hi David Leimbach wrote: On Mon, Mar 22, 2010 at 6:10 AM, Johan Tibell johan.tib...@gmail.com wrote: On Mon, Mar 22, 2010 at 1:16 PM, Johann Höchtl johann.hoec...@gmail.com wrote: My question or discussion point: Why not depreciate [Char] altogether