Re: [Haskell-cafe] Most used functions in hackage

2013-01-29 Thread Casey Basichis
Hi Dmitry, Thanks for the links. I've been through the 24 Days of Hackage, but I think its time to run through them again now that I'm a little more familiar with everything. Why do you think browsing function by function is a bad idea? It seems that knowing exactly what the most used

[Haskell-cafe] list comprehansion performance has hug different

2013-01-29 Thread Junior White
Hi Cafe, I have two programs for the same problem Eight queens problem, the link is http://www.haskell.org/haskellwiki/99_questions/90_to_94. My two grograms only has little difference, but the performance, this is my solution: -- solution

Re: [Haskell-cafe] list comprehansion performance has hug different

2013-01-29 Thread Artyom Kazak
Junior White efi...@gmail.com писал(а) в своём письме Tue, 29 Jan 2013 12:25:49 +0300: The only different in the two program is in the first is q - [1..n], qs - queens' (k-1), and the second is qs - queens' (k-1), q - [1..n]. In the first case `queens' (k-1)` is being recomputed for every q

Re: [Haskell-cafe] list comprehansion performance has hug different

2013-01-29 Thread Junior White
Hi Artyom, Thanks! But I don't understand why in the first case queens' (k-1) is being recomputed n times? On Tue, Jan 29, 2013 at 5:31 PM, Artyom Kazak artyom.ka...@gmail.comwrote: Junior White efi...@gmail.com писал(а) в своём письме Tue, 29 Jan 2013 12:25:49 +0300: The only

Re: [Haskell-cafe] list comprehansion performance has hug different

2013-01-29 Thread Artyom Kazak
Junior White efi...@gmail.com писал(а) в своём письме Tue, 29 Jan 2013 12:40:08 +0300: Hi Artyom, Thanks! But I don't understand why in the first case queens' (k-1) is being recomputed n times? Because your list comprehension is just a syntactic sugar for concatMap (\q -

Re: [Haskell-cafe] list comprehansion performance has hug different

2013-01-29 Thread Junior White
Thanks again! I understand now. I'll be careful when the next time I use list comprehension. On Tue, Jan 29, 2013 at 5:48 PM, Artyom Kazak artyom.ka...@gmail.comwrote: Junior White efi...@gmail.com писал(а) в своём письме Tue, 29 Jan 2013 12:40:08 +0300: Hi Artyom, Thanks! But I don't

Re: [Haskell-cafe] list comprehansion performance has hug different

2013-01-29 Thread Junior White
So this is a problem in lazy evaluation language, it will not appear in python or erlang, am i right? On Tue, Jan 29, 2013 at 5:54 PM, Junior White efi...@gmail.com wrote: Thanks again! I understand now. I'll be careful when the next time I use list comprehension. On Tue, Jan 29, 2013 at

Re: [Haskell-cafe] Most used functions in hackage

2013-01-29 Thread Henk-Jan van Tuyl
On Tue, 29 Jan 2013 09:23:34 +0100, Casey Basichis caseybasic...@gmail.com wrote: I guess what I'm looking for doesn't exist, which is what it is. I'm just interested in why it's not an ideal way to take in Haskell, starting with the common and moving to the to rare. It is worth while

Re: [Haskell-cafe] list comprehansion performance has hug different

2013-01-29 Thread Artyom Kazak
Junior White efi...@gmail.com писал(а) в своём письме Tue, 29 Jan 2013 12:59:31 +0300: So this is a problem in lazy evaluation language, it will not appear in python or erlang, am i right? Not quite. Compilers of imperative languages don’t perform CSE (common subexpression elimination)

Re: [Haskell-cafe] quotRem and divMod

2013-01-29 Thread Daniel Fischer
On Tuesday 29 January 2013, 03:27:41, Artyom Kazak wrote: Hi! I’ve always thought that `quotRem` is faster than `quot` + `rem`, since both `quot` and `rem` are just wrappers that compute both the quotient and the remainder and then just throw one out. However, today I looked into the

Re: [Haskell-cafe] quotRem and divMod

2013-01-29 Thread Artyom Kazak
Shachaf Ben-Kiki shac...@gmail.com писал(а) в своём письме Tue, 29 Jan 2013 09:09:37 +0300: That code is from base 4.5. Here's base 4.6: quotRem x@(I32# x#) y@(I32# y#) | y == 0 = divZeroError -- Note [Order of tests] | y == (-1) x ==

Re: [Haskell-cafe] catamorphisms and attribute grammars

2013-01-29 Thread Ross Paterson
On Sun, Jan 27, 2013 at 12:20:25AM +, Roman Cheplyaka wrote: Very nice! This can be generalized to arbitrary arrows: {-# LANGUAGE ExistentialQuantification #-} import Prelude hiding (id) import Control.Arrow import Control.Applicative import Control.Category data F

Re: [Haskell-cafe] Type classes, collections, sum types, closures, and a massive headache

2013-01-29 Thread Evan Laforge
Today I thought it was about time to simplify how new 'things' of a certain kind are added to the system. These things are some a cross between an event and an assertion of a fact in a rule based system. There are many different kinds of these things. I already have more than a dozen

Re: [Haskell-cafe] Uniplate and rewriting with different types

2013-01-29 Thread Neil Mitchell
Hi Chris, With the following type, and transformation functions: data Odd = OddOne Even | OddZero Even deriving (Data,Typeable,Show) data Even = EvenOne Odd | EvenZero Odd | Nil deriving (Data,Typeable,Show) t1,t2,t3 :: Even - Maybe Even But if one of the

[Haskell-cafe] Heads up: planned removal of String instances from HTTP package

2013-01-29 Thread Ganesh Sittampalam
Hi, tl;dr: I'm planning on removing the String instances from the HTTP package. This is likely to break code. Obviously it will involve a major version bump. The basic reason is that this instance is rather broken in itself. A String ought to represent Unicode data, but the HTTP wire format is

Re: [Haskell-cafe] Heads up: planned removal of String instances from HTTP package

2013-01-29 Thread Johan Tibell
On Tue, Jan 29, 2013 at 2:15 PM, Ganesh Sittampalam gan...@earth.li wrote: tl;dr: I'm planning on removing the String instances from the HTTP package. This is likely to break code. Obviously it will involve a major version bump. The basic reason is that this instance is rather broken in

[Haskell-cafe] Handling exceptions or gracefully releasing resources

2013-01-29 Thread Thiago Negri
`Control.Exception.bracket` is a nice function to acquire and release a resource in a small context. But, how should I handle resources that are hold for a long time? Should I put `Control.Exception.finally` on every single line of my finalizers? What exceptions may occur on an IO operation?

Re: [Haskell-cafe] Handling exceptions or gracefully releasing resources

2013-01-29 Thread Johan Tibell
Hi, The pattern is essentially the same as in imperative languages; every allocation should involve a finally clause that deallocates the resource. On Tue, Jan 29, 2013 at 2:59 PM, Thiago Negri evoh...@gmail.com wrote: Should I put `Control.Exception.finally` on every single line of my

Re: [Haskell-cafe] list comprehansion performance has hug different

2013-01-29 Thread Richard O'Keefe
On 29/01/2013, at 10:59 PM, Junior White wrote: So this is a problem in lazy evaluation language, it will not appear in python or erlang, am i right? Wrong. Let's take Erlang: [f(X, Y) || X - g(), Y - h()] Does the order of the generators matter here? You _bet_ it does. First off,

Re: [Haskell-cafe] list comprehansion performance has hug different

2013-01-29 Thread wren ng thornton
On 1/29/13 4:25 AM, Junior White wrote: Hi Cafe, I have two programs for the same problem Eight queens problem, the link is http://www.haskell.org/haskellwiki/99_questions/90_to_94. My two grograms only has little difference, but the performance, this is my solution: The difference is

Re: [Haskell-cafe] Heads up: planned removal of String instances from HTTP package

2013-01-29 Thread Ganesh Sittampalam
On 29/01/2013 22:46, Johan Tibell wrote: On Tue, Jan 29, 2013 at 2:15 PM, Ganesh Sittampalam gan...@earth.li wrote: tl;dr: I'm planning on removing the String instances from the HTTP package. This is likely to break code. Obviously it will involve a major version bump. I think it's the