Re[2]: [Haskell-cafe] Abstraction leak

2007-07-01 Thread Bulat Ziganshin
Hello Andrew, Saturday, June 30, 2007, 11:48:19 AM, you wrote: me too :) but i never used Haskell for compression itself, only for managing archives. fast compression routines are written in C++ What, you're telling me that fast software cannot be written in Haskell? :-P in my

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Andrew Coppin
apfelmus wrote: Am I missing something or why wouldn't encode, decode :: String - String encode = encodeRLE . encodeHuffman decode = decodeHuffman . decodeRLE do the job? This is probably what Andrew intends to do in his Java version. Note that this not only RLE-encodes the Huffman table

[Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread apfelmus
Andrew Coppin wrote: apfelmus wrote: Am I missing something or why wouldn't encode, decode :: String - String encode = encodeRLE . encodeHuffman decode = decodeHuffman . decodeRLE do the job? This is probably what Andrew intends to do in his Java version. Note that this not only

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Andrew Coppin
apfelmus wrote: Andrew Coppin wrote: It is enough. But given that the whole purpose of compression algorithms is to squeeze data into the tiniest possible space, I wanted to avoid having a size field. And mathematically it's perfectly possible to do... I just can't find a convinient way to

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Andrew Coppin
OK, well I don't know the Parsec types and function names off the top of my head, but suppose I have the following: runParser :: Parser a b - [a] - Either ParseError b parseHuffmanTable :: [x] - Parser Word8 (HuffmanTable x) parseHuffmanPayload :: HuffmanTable x - Parser Word8 [x]

Re: [Haskell-cafe] Parsers are monadic?

2007-07-01 Thread Claus Reinke
When you pretend you've never heard of monads or arrows, and write down the types what do you get? this question made me wonder whether i could still recall how i used to write parsers before i heard of monads or arrows. it is difficult not to fall back into the pattern of state transformer

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Andrew Coppin
apfelmus wrote: Andrew Coppin wrote: OK, I'm stuck now. :-S 1. How do I run the input through parseRLE and *then* through parseHuffmanTable? 2. How do I get parseHuffmanPayload to continue from where parseRLE left off? (How do I get parseRLE to not parse the entire input, for that

Re: [Haskell-cafe] sha1 implementation thats only 12 times slower then C

2007-07-01 Thread Bulat Ziganshin
Hello Anatoly, Sunday, July 1, 2007, 3:58:24 AM, you wrote: Anyone have any pointers on how to get hashElem and updateElem to run faster, or any insight on what exactly they are allocating. To me it seems that those functions should be able to do everything they need to without a malloc.

Re[2]: [Haskell-cafe] Abstraction leak

2007-07-01 Thread Bulat Ziganshin
Hello Andrew, Sunday, July 1, 2007, 1:18:16 PM, you wrote: encoding is simple - make this traversal one time and store bit sequence for each symbol. for decoding, you can find length of longest symbol MaxBits and build table of 2^MaxBits elements which allows to find next symbol by direct

Re: [Haskell-cafe] Abstraction leak

2007-07-01 Thread Andrew Coppin
Bulat Ziganshin wrote: Hello Andrew, I see. So build a table of codes and bitmasks and test against that... decodeSymbol = do n - returnNextNBits MaxBits -- this operation doesn't forward input pointer! symbol - table1 ! n bits - table2 ! symbol skipNBits bits return

Re: [Haskell-cafe] Parsers are monadic?

2007-07-01 Thread Paul Hudak
Hi Claus. I am sympathetic with your comments regarding monads and continuations. It's interesting to note that the original I/O system in Haskell was based on streams and continuations. The continuation version had two continuations in fact -- one for success and one for failure. For

Re: [Haskell-cafe] Language semantics

2007-07-01 Thread Andrew Coppin
Stefan O'Rear wrote: This is *much* easier expressed as a bottom-up traversal. compile = transform optimize . transform eliminate eliminate (Lam v e) = transform (abstract v) e eliminate x = x abstract v (Var v') | v == v' = I abstract v (a :@ b) = S :@ a :@ b abstract v x = x optimize (S

Re: [Haskell-cafe] Language semantics

2007-07-01 Thread Stefan O'Rear
On Sun, Jul 01, 2007 at 05:06:10PM +0100, Andrew Coppin wrote: Stefan O'Rear wrote: This is *much* easier expressed as a bottom-up traversal. compile = transform optimize . transform eliminate eliminate (Lam v e) = transform (abstract v) e eliminate x = x abstract v (Var v') | v == v'

[Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Jon Fairbairn
Andrew Coppin [EMAIL PROTECTED] writes: While we're on the subject... am I the first person to notice that Haskell doesn't appear to have much support for fiddling with streams of bits? No. Presumably the author of Data.Bits noticed some lack. (Note that Integer is an instance of Num and

Re: [Haskell-cafe] sha1 implementation thats only 12 times slower then C

2007-07-01 Thread Hugh Perkins
Just an outsider's reaction, and for all I know unsafeRead is actually safe, but if the point of using Haskell (and I'm still trying to discover what that is ;-) ) is either to be able to rigorously mathematically prove that your program will work perfectly (target usage 1), or to carry out

Re: [Haskell-cafe] Abstraction leak

2007-07-01 Thread Josef Svenningsson
On 6/30/07, Jon Cast [EMAIL PROTECTED] wrote: On Friday 29 June 2007, Jon Cast wrote: Here's my solution (drawn from a library I'll be posting Real Soon Now): snip solution I forgot to point out that this is 75-90% drawn from a library called Fudgets[1], which is probably the most extended

Re: [Haskell-cafe] XmlSerializer.deserialize?

2007-07-01 Thread Hugh Perkins
On 6/26/07, Udo Stenzel [EMAIL PROTECTED] wrote: That's another way of saying that the truly powerful features are missing from C#... Hi Udo, Genuine question: please could you tell me what are the truly powerful features of Haskell? My own personal interest comes from a presentation by

Re: [Haskell-cafe] Re: Abstraction leak

2007-07-01 Thread Andrew Coppin
Jon Fairbairn wrote: Andrew Coppin [EMAIL PROTECTED] writes: While we're on the subject... am I the first person to notice that Haskell doesn't appear to have much support for fiddling with streams of bits? No. Presumably the author of Data.Bits noticed some lack. (Note that Integer

Re: [Haskell-cafe] Language semantics

2007-07-01 Thread Andrew Coppin
Stefan O'Rear wrote: On Sun, Jul 01, 2007 at 05:06:10PM +0100, Andrew Coppin wrote: Um... shouldn't that read abstract v (a :@ b) = S :@ (transform (abstract v) a) :@: (transform (abstract v) b) No, because the whole point of transform is that it handles recursion for you. OK.

Re: [Haskell-cafe] sha1 implementation thats only 12 times slower then C

2007-07-01 Thread Benja Fallenstein
Hi, 2007/7/1, Bulat Ziganshin [EMAIL PROTECTED]: aa - unsafeRead a5 0 return $! aa bb - unsafeRead a5 1 return $! bb If this is a useful pattern, would it make sense to have a function to encapsulate it? mseq :: Monad m = m a - m a mseq m = m = (return $!) - Benja

[Haskell-cafe] TT check

2007-07-01 Thread Andrew Coppin
Can somebody check that I've implemented this correctly? *X*X*X*XX***X*X*XXX*X*X*XX***X*X*X*XX**X*X*XX**X*X*X*XX ***X*X*XXX*X*X*XX**XX*X*XX***X*X*XXX*X*XXX*X*X*XXX* X*X*XX***X*X*XXX*X*X*XXX*X*X*X*XXXX*X*X*XX***X* X*XXX*X*X*XXX*X* A parser for this is given by

Re: [Haskell-cafe] Language semantics

2007-07-01 Thread Mark T.B. Carroll
Andrew Coppin [EMAIL PROTECTED] writes: (snip) (Does anybody else on this list frequently get the feeling their IQ is just too low for Haskell??) I do. But then, when I finally understand something, it seems easy and simple and I'm not sure why it wasn't obvious all along. -- Mark

Re: [Haskell-cafe] Language semantics

2007-07-01 Thread Felipe Almeida Lessa
On 7/1/07, Andrew Coppin [EMAIL PROTECTED] wrote: (Does anybody else on this list frequently get the feeling their IQ is just too low for Haskell??) That's the best part of learning Haskell. You're always in touch with the very best people --- directly or indirectly (i.e. using their libraries

Re: [Haskell-cafe] sha1 implementation thats only 12 times slower then C

2007-07-01 Thread Anatoly Yakovenko
so using mseq didn't seem to make any difference, i still had the same performance. On 7/1/07, Benja Fallenstein [EMAIL PROTECTED] wrote: Hi, 2007/7/1, Bulat Ziganshin [EMAIL PROTECTED]: aa - unsafeRead a5 0 return $! aa bb - unsafeRead a5 1 return $! bb If this is a useful

Re: [Haskell-cafe] TT check

2007-07-01 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Andrew Coppin wrote: decode (c:cs) = case c of 'X' - X '*' - let (e0,cs0) = decode cs; (e1,cs1) = decode cs0 in (e0 `apply` e1, cs1) The letter X stands for the following combinator: X = \x - xSK K = \xy - x S = \fgx - fx(gx)

Re: [Haskell-cafe] Language semantics

2007-07-01 Thread Andrew Coppin
Mark T.B. Carroll wrote: Andrew Coppin [EMAIL PROTECTED] writes: (snip) (Does anybody else on this list frequently get the feeling their IQ is just too low for Haskell??) I do. But then, when I finally understand something, it seems easy and simple and I'm not sure why it wasn't

Re: [Haskell-cafe] Language semantics

2007-07-01 Thread Andrew Coppin
Felipe Almeida Lessa wrote: On 7/1/07, Andrew Coppin [EMAIL PROTECTED] wrote: (Does anybody else on this list frequently get the feeling their IQ is just too low for Haskell??) That's the best part of learning Haskell. You're always in touch with the very best people --- directly or

Re: [Haskell-cafe] TT check

2007-07-01 Thread Miguel Mitrofanov
Hi Andrew! Seems that you've made a typo or something... module Term where import Control.Monad.State testData = *X*X*X*XX**X*X*XX*X*X*X*XX*X*X*XX***X*X*X*XX ++ ***X*X*X*XX**X*X*XX*X*X*X*XX*X*X*XX*XX***X*X*X*X ++ X***X*X*X*XX**X*X*XX*X*X*X*XX*X*X*XX*XX data Term =

Re: [Haskell-cafe] TT check

2007-07-01 Thread Andrew Coppin
Wait a sec... I found a way. Sort of. http://ling.ucsd.edu/~barker/Iota/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Parsers are monadic?

2007-07-01 Thread Jon Cast
On Saturday 30 June 2007, Claus Reinke wrote: The standard, naïve approach to monadic parsing is very nice, but inefficient. So *please read* some material based on HuttonMeijer approach, but don't stay there, read something more modern, since we thereby seem to have left the phase of simple

Re: [Haskell-cafe] Parsers are monadic?

2007-07-01 Thread Hugh Perkins
Big Chris wrote: http://www.cs.nott.ac.uk/~gmh/bib.html#monparsing Hey, just to say, the first few pages of this explain monads really well. Good reference :-) It's the first introduction to monads I've seen that describes monads directly, without using analogies, and manages to be both

Re[2]: [Haskell-cafe] XmlSerializer.deserialize?

2007-07-01 Thread Bulat Ziganshin
Hello Hugh, Sunday, July 1, 2007, 8:56:05 PM, you wrote: Genuine question: please could you tell me what are the truly powerful features of Haskell? Anyway, getting back to my question, there's a whole slew of articles around saying that no-one uses Haskell because they're too stupid. 

Re: Re[2]: [Haskell-cafe] XmlSerializer.deserialize?

2007-07-01 Thread Hugh Perkins
Ok good info :-) btw, are you read Hoar's book Communicating Sequential Processes? i think that his model is very FPish and reading his book should allow to switch your look at concurrency in right direction No, I'll check it out. On 7/1/07, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello

Re: Re[2]: [Haskell-cafe] XmlSerializer.deserialize?

2007-07-01 Thread Hugh Perkins
Well, figured out a solution to parsing xml. It's not really pretty, but it works. Basically we just convert the incoming xml into a gread compatible format then use gread :-D If someone has a more elegant solution, please let me know. module ParseXml where import IO import Char import

Re: Re[2]: [Haskell-cafe] XmlSerializer.deserialize?

2007-07-01 Thread Philip Armstrong
On Sun, Jul 01, 2007 at 10:48:11PM +0200, Hugh Perkins wrote: On 7/1/07, Bulat Ziganshin [EMAIL PROTECTED] wrote: btw, are you read Hoar's book Communicating Sequential Processes? i think that his model is very FPish and reading his book should allow to switch your look at

Re: Re[2]: [Haskell-cafe] XmlSerializer.deserialize?

2007-07-01 Thread Hugh Perkins
Clll :-) Thanks for the link. Er are you the Philip Armstrong I was at college with ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: Parsers are monadic?

2007-07-01 Thread Alexis Hazell
On Sunday 01 July 2007 09:34, Gregory Propf wrote: Thanks, that was helpful. I didn't realize that there were pure functional monads. Neither did i; the general impression i'd got after almost a year of trying to learn Haskell was: Monad Eisley Spaceport. You will never find a more wretched