Re: [Haskell-cafe] Why so many strings in Network.URI, System.Posix and similar libraries?

2012-03-12 Thread Joey Hess
Jason Dusek wrote: :info System.Posix.Env.getEnvironment System.Posix.Env.getEnvironment :: IO [(String, String)] -- Defined in System.Posix.Env But there is no law that environment variables must be made of characters: The recent ghc release provides

Re: [Haskell-cafe] Helper classes for Generics

2012-03-12 Thread José Pedro Magalhães
Hi Reiner, It is indeed not strictly necessary to define such helper classes for kind * generic functions. You do need them for kind * - * functions, though. Also, I think they should always be used because they help keep things separate. If we use an implementation of generics with DataKinds

Re: [Haskell-cafe] Global Arrays

2012-03-12 Thread Ketil Malde
Clark Gaebel cgae...@csclub.uwaterloo.ca writes: In Haskell, what's the canonical way of declaring a top-level array (Data.Vector of a huge list of doubles, in my case)? Performance is key in my case. The straightforward way would just be something like: globalArray :: V.Vector Double

Re: [Haskell-cafe] using mutable data structures in pure functions

2012-03-12 Thread Stephen Tetley
There is a trick to `nub` where you couldn't implement the internal lookup list with an (assumed faster) search tree anyway. `nub` only mandates equality not ordering, so building a ordered structure like a binary tree is impossible. In practice i would be hard to beat list as the intermediate

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-12 Thread Paolo Capriotti
On Mon, Mar 12, 2012 at 3:26 AM, Chris Smith cdsm...@gmail.com wrote: With pipes-core (which, recall, is known to be unsound... just felt this is a good time for a reminder of that, even though I believe the subset that adds tryAwait and forP to be sound), you do get both (pipe id) and (forP

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-12 Thread Paolo Capriotti
On Mon, Mar 12, 2012 at 2:53 AM, Mario Blažević blama...@acanac.net wrote:    May I enquire what was the reason for the non-termination of idP? Why was it not defined as 'forP yield' instead? The following command runs the way I expected. The identity in a homset is unique, and in the case of

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-12 Thread Paolo Capriotti
On Sun, Mar 11, 2012 at 10:41 PM, Chris Smith cdsm...@gmail.com wrote: On Sun, Mar 11, 2012 at 2:33 PM, Twan van Laarhoven twa...@gmail.com wrote: I think you should instead move unwaits in and out of the composition on the left side:    unawait x (p1 + p2) === (unawait x p1) + p2 This

Re: [Haskell-cafe] Associative prefix operators in Parsec

2012-03-12 Thread Christian Maeder
Am 08.03.2012 17:16, schrieb Troels Henriksen: Christian Maederchristian.mae...@dfki.de writes: The simplest solution is to parse the prefixes yourself and do not put it into the table. (Doing the infixes and | by hand is no big deal, too, and possibly easier then figuring out the

Re: [Haskell-cafe] Understanding GC time

2012-03-12 Thread Steffen Schuldenzucker
On 03/10/2012 07:50 PM, Thiago Negri wrote: I see. Thanks for the answers. Any data structure or source annotation that would prevent that? For example, if I try the same program to run on a [1..] list, I'll get an out of memory error for the single-threaded version. Any way

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-12 Thread Twan van Laarhoven
On 11/03/12 23:41, Chris Smith wrote: On Sun, Mar 11, 2012 at 2:33 PM, Twan van Laarhoventwa...@gmail.com wrote: I think you should instead move unwaits in and out of the composition on the left side: unawait x (p1+ p2) === (unawait x p1)+ p2 This makes idP a left-identity for (+),

Re: [Haskell-cafe] Question about concurrency, threads and GC

2012-03-12 Thread Paul Graphov
Hi! Thanks to all who responded! I got a lot of information to read and think about. For now I decided to use stm-channelize as the simplest approach which seem to be enough. On Mon, Mar 5, 2012 at 9:50 PM, Alexander V Vershilov alexander.vershi...@gmail.com wrote: Hello. I've also written

Re: [Haskell-cafe] Global Arrays

2012-03-12 Thread Clark Gaebel
Is there any proof of this? I'm not familiar enough with core to check. On Mon, Mar 12, 2012 at 3:48 AM, Ketil Malde ke...@malde.org wrote: Clark Gaebel cgae...@csclub.uwaterloo.ca writes: In Haskell, what's the canonical way of declaring a top-level array (Data.Vector of a huge list of

Re: [Haskell-cafe] ANNOUNCE: pipes-core 0.0.1

2012-03-12 Thread Chris Smith
On Mon, Mar 12, 2012 at 3:26 AM, Paolo Capriotti p.caprio...@gmail.com wrote: I wouldn't say it's unsound, more like not yet proved to be bug-free :) Note that the latest master fixes all the issues found so far. I was referring to the released version of pipes-core, for which known to be

[Haskell-cafe] Is there a better way to subtyping?

2012-03-12 Thread Jeff Shaw
More specifically, if I have a record type from which I construct multiple sub-record types, and I want to store these in a collection which I want to map over while preserving the ability to get at the sub-fields, is there a better way to do it than to have an enumeration for the sub-types

Re: [Haskell-cafe] Helper classes for Generics

2012-03-12 Thread Yves Parès
I'd have a question concerning GHC.Generics: how does it relate to SYB's Data.Generics? Is it intended to replace it or complete it? In other words: does class Data.Generics.Data class do things that class GHC.Generics.Generic can't do? Le 12 mars 2012 04:27, Reiner Pope reiner.p...@gmail.com a

Re: [Haskell-cafe] Helper classes for Generics

2012-03-12 Thread José Pedro Magalhães
Hi Yves, GHC.Generics [1] and SYB [2] are two rather different approaches to generic programming. There are things that can be done in one but not in the other, and there are things that are easier on one rather than the other. For instance, SYB tends to be very useful for large AST

Re: [Haskell-cafe] Helper classes for Generics

2012-03-12 Thread Yves Parès
Thanks for the clarification. But could not class Data have been used for generic Deriving of classes? I imagine it would have been harder, but I fail to see if would have been possible... Le 12 mars 2012 16:58, José Pedro Magalhães j...@cs.uu.nl a écrit : Hi Yves, GHC.Generics [1] and SYB

Re: [Haskell-cafe] Helper classes for Generics

2012-03-12 Thread José Pedro Magalhães
It could, yes. Actually, using DefaultSignatures you can probably use SYB for defining classes with generic default methods, by adding Data and Typeable constraints instead of Generic. Cheers, Pedro 2012/3/12 Yves Parès yves.pa...@gmail.com Thanks for the clarification. But could not class

[Haskell-cafe] Empty Input list

2012-03-12 Thread Kevin Clees
Dear Haskell friends, what can I do, if a function gets an empty input list? I want, that it only returns nothing. This is my source code: tmp:: [(Int, Int)] - Int - (Int, Int) tmp (x:xs) y | y == 1 = x | y 1 = tmp xs (y-1) If this function gets an empty list, he throws

Re: [Haskell-cafe] IO() and other datatypes

2012-03-12 Thread Kevin Clees
Great, Thank you ! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Empty Input list

2012-03-12 Thread Chris Smith
On Mon, Mar 12, 2012 at 2:41 PM, Kevin Clees k.cl...@web.de wrote: what can I do, if a function gets an empty input list? I want, that it only returns nothing. This is my source code: tmp:: [(Int, Int)] - Int - (Int, Int) tmp (x:xs) y        | y == 1 = x        | y 1 = tmp xs (y-1) It's

Re: [Haskell-cafe] Empty Input list

2012-03-12 Thread Chris Smith
Oh, and just to point this out, the function you're writing already exists in Data.List. It's called (!!). Well, except that it's zero indexed, so your function is more like: tmp xs y = xs !! (y-1) ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Empty Input list

2012-03-12 Thread Kevin Clees
Hey Chris, thank you for your help! Your last comment with the (!!)-thing was a very good idea! Now my function looks like this: tmp:: [(Int, Int)] - Int - (Int, Int) tmp [] y = (0,0) tmp xs y = xs !! (y-1) If the function returns (0,0) it will blocked by another function. If I want to

Re: [Haskell-cafe] Empty Input list

2012-03-12 Thread Chris Smith
On Mon, Mar 12, 2012 at 3:14 PM, Kevin Clees k.cl...@web.de wrote: Now my function looks like this: tmp:: [(Int, Int)] - Int - (Int, Int) tmp [] y = (0,0) tmp xs y = xs !! (y-1) Just a warning that this will still crash if the list is non-empty by the index exceeds the length. That's

[Haskell-cafe] Leksah Install Issue (cabal experts please help)

2012-03-12 Thread Hamish Mackenzie
pozic raised an install issue on IRC. Basically he was getting... ~$ cabal install leksah-server Resolving dependencies... cabal: Couldn't read cabal file leksah-server/0.12.0.3/leksah-server.cabal To reproduce this issue. Use GHC 6.12.3, 7.0.3 or 7.2.2 to cabal install cabal-install then run

Re: [Haskell-cafe] Leksah Install Issue (cabal experts please help)

2012-03-12 Thread Ivan Lazar Miljenovic
On 13 March 2012 12:33, Hamish Mackenzie hamish.k.macken...@googlemail.com wrote: pozic raised an install issue on IRC.  Basically he was getting... ~$ cabal install leksah-server Resolving dependencies... cabal: Couldn't read cabal file leksah-server/0.12.0.3/leksah-server.cabal To

Re: [Haskell-cafe] Leksah Install Issue (cabal experts please help)

2012-03-12 Thread Hamish Mackenzie
On 13 Mar 2012, at 15:56, Ivan Lazar Miljenovic wrote: Even if you cabal unpack and then modify the .cabal file and run cabal install it still fails with the same error. How did you modify it? Did you change the cabal-version field as well? I changed cabal-version and removed the

Re: [Haskell-cafe] Leksah Install Issue (cabal experts please help)

2012-03-12 Thread Hamish Mackenzie
On 13 Mar 2012, at 16:51, Hamish Mackenzie wrote: On 13 Mar 2012, at 15:56, Ivan Lazar Miljenovic wrote: Even if you cabal unpack and then modify the .cabal file and run cabal install it still fails with the same error. How did you modify it? Did you change the cabal-version field as

Re: [Haskell-cafe] Leksah Install Issue (cabal experts please help)

2012-03-12 Thread Hamish Mackenzie
On 13 Mar 2012, at 16:56, Hamish Mackenzie wrote: On 13 Mar 2012, at 16:51, Hamish Mackenzie wrote: On 13 Mar 2012, at 15:56, Ivan Lazar Miljenovic wrote: Even if you cabal unpack and then modify the .cabal file and run cabal install it still fails with the same error. How did you

Re: [Haskell-cafe] Leksah Install Issue (cabal experts please help)

2012-03-12 Thread Ivan Lazar Miljenovic
On 13 March 2012 15:03, Hamish Mackenzie hamish.k.macken...@googlemail.com wrote: On 13 Mar 2012, at 16:56, Hamish Mackenzie wrote: On 13 Mar 2012, at 16:51, Hamish Mackenzie wrote: On 13 Mar 2012, at 15:56, Ivan Lazar Miljenovic wrote: Even if you cabal unpack and then modify the .cabal

Re: [Haskell-cafe] Empty Input list

2012-03-12 Thread Chris Wong
On Tue, Mar 13, 2012 at 12:24 PM, Chris Smith cdsm...@gmail.com wrote: On Mon, Mar 12, 2012 at 3:14 PM, Kevin Clees k.cl...@web.de wrote: Now my function looks like this: tmp:: [(Int, Int)] - Int - (Int, Int) tmp [] y = (0,0) tmp xs y = xs !! (y-1) Just a warning that this will still crash

Re: [Haskell-cafe] Leksah Install Issue (cabal experts please help)

2012-03-12 Thread Hamish Mackenzie
This also works... cabal install --constrain='Cabal=1.10.2' cabal-install cabal install leksah-server Wouldn't just a cabal update cabal install cabal-install work to bring in the newest version of cabal-install (which requires Cabal-1.10.*) ? Cabal 1.10.1 is installed with ghc 7.0.3

Re: [Haskell-cafe] Leksah Install Issue (cabal experts please help)

2012-03-12 Thread Ivan Lazar Miljenovic
On 13 March 2012 15:28, Hamish Mackenzie hamish.k.macken...@googlemail.com wrote: This also works... cabal install --constrain='Cabal=1.10.2' cabal-install cabal install leksah-server Wouldn't just a cabal update cabal install cabal-install work to bring in the newest version of