Re: [Haskell-cafe] Contributing to http-conduit

2012-02-06 Thread Michael Snoyman
Just an FYI for everyone: Myles sent an (incredibly thorough) pull request to handle cookies: https://github.com/snoyberg/http-conduit/pull/13 Thanks! On Sun, Feb 5, 2012 at 8:20 AM, Myles C. Maxfield myles.maxfi...@gmail.com wrote: 1. The spec defines a grammar for the attributes. They're in

[Haskell-cafe] Problem resolving: Hangman

2012-02-06 Thread Haisheng Wu
Though the problem I'd ask is not quiet related to haskell, I hope talent people here could provide some suggestions. The problem is not just solve the Hangman problem but solve it in sort of AI way. General idea is : 1. Randomly pick words, e.g. 20 from a predefined word list file. (

Re: [Haskell-cafe] Rewrite this imperative in FP way

2012-02-06 Thread Haisheng Wu
The reason I redefined Eq is: When doing `union` over two list of MyTuple is just base on its first element. Basically it means: [(1,2), (2,2)] `union` [(1,0), (2,0), (0,0)] produce [(1,2), (2,2), (0,0)] rather than [(1,2),(2,2),(1,0),(2,0),(0,0)] by default. -Haisheng On Sun, Feb 5, 2012

Re: [Haskell-cafe] Rewrite this imperative in FP way

2012-02-06 Thread Haisheng Wu
*d = [sum $ map (a !!) [i | i - b, j - c, i + j 3, i + j == dIndex] | dIndex - [0..3]] * This is cool. -Simon On Sun, Feb 5, 2012 at 5:07 PM, L Corbijn aspergesoe...@gmail.com wrote: On Sun, Feb 5, 2012 at 7:28 AM, Haisheng Wu fre...@gmail.com wrote: a = [1,1,1,1] b = [0,1,2,3] d =

Re: [Haskell-cafe] Rewrite this imperative in FP way

2012-02-06 Thread Yves Parès
Okay. But that's misleading, as normally x == y = True *iff* compare x y = EQ, but there this is not verified, as you don't redefined A function like unionBy doesn't exist, so IMHO to limit ambiguity, it would be a good idea to use MyTuple *only *at the specific place where you need its Eq

Re: [Haskell-cafe] ANN: Updated OpenGL libraries

2012-02-06 Thread Alberto Ruiz
Thanks!!! On 02/05/2012 11:53 PM, Jason Dagit wrote: Hello, I'm pleased to anounce a minor bug fix release of the OpenGL libraries. This release was prompted by issues and warnings when compiling with ghc-7.4.1. The following packages have been updated: * OpenGLRaw 1.2.0.0 * OpenGL

Re: [Haskell-cafe] Rewrite this imperative in FP way

2012-02-06 Thread Thomas Hallgren
How about this: import Array a = [1,1,1,1] b = [0,1,2,3] c = [0,2] d = elems $ accumArray (+) 0 (0,3) [(i+j,a!!i) | i-b, j-c, i+j3] -- Thomas H On 2012-02-06 12:01 , Haisheng Wu wrote: *d = [sum $ map (a !!) [i | i - b, j - c, i + j 3, i + j == dIndex] | dIndex - [0..3]] *

Re: [Haskell-cafe] ANN: exists-0.1

2012-02-06 Thread Tillmann Rendel
Hi, Gábor Lehel wrote: data E = forall a. C a = E a I don't know if anyone's ever set out what the precise requirements are for a type class method to be useful with existentials. More than you seem to think. For example: data Number = forall a . Num a = Number a foo :: Number - Number

Re: [Haskell-cafe] ANNOUNCE: system-filepath 0.4.5 and system-fileio 0.3.4

2012-02-06 Thread Joey Hess
John Millikin wrote: That was my understanding also, then QuickCheck found a counter-example. It turns out that there are cases where a valid path cannot be roundtripped in the GHC 7.2 encoding. The issue is that [238,189,178] decodes to 0xEF72, which is within the 0xEF00-0xEFFF range that

Re: [Haskell-cafe] ANNOUNCE: system-filepath 0.4.5 and system-fileio 0.3.4

2012-02-06 Thread John Millikin
On Mon, Feb 6, 2012 at 10:05, Joey Hess j...@kitenet.net wrote: John Millikin wrote: That was my understanding also, then QuickCheck found a counter-example. It turns out that there are cases where a valid path cannot be roundtripped in the GHC 7.2 encoding. The issue is that  [238,189,178]

Re: [Haskell-cafe] ANN: exists-0.1

2012-02-06 Thread Gábor Lehel
If anyone ever says, I'd really like to use your package if it weren't for the dependencies, I'll very gladly remove them. (They're used for actual instances, by the way, not just the Defaults module.) 2012/2/6 Yves Parès yves.pa...@gmail.com: That is a great initiative. I didn't know about

Re: [Haskell-cafe] ANN: exists-0.1

2012-02-06 Thread Gábor Lehel
2012/2/6 Tillmann Rendel ren...@informatik.uni-marburg.de: Hi, Gábor Lehel wrote: data E = forall a. C a = E a I don't know if anyone's ever set out what the precise requirements are for a type class method to be useful with existentials. More than you seem to think. For example:  

[Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
Using the OpenGL package on Hackage, how do I load a texture from an array? In the red book[1], I see their code using glGenTextures and glBindTexture, but I can't find these in the documentation. Are there different functions I should be calling? [1] http://glprogramming.com/red/chapter09.html

Re: [Haskell-cafe] [Haskell] ANNOUNCE: system-filepath 0.4.5 and system-fileio 0.3.4

2012-02-06 Thread Ian Lynagh
On Sun, Feb 05, 2012 at 07:17:32PM -0800, John Millikin wrote: That was my understanding also, then QuickCheck found a counter-example. It turns out that there are cases where a valid path cannot be roundtripped in the GHC 7.2 encoding. This is fixed in GHC 7.4.1. Thanks Ian

[Haskell-cafe] network-2.3.0.10 compiled for ghc 7.4.1 windows

2012-02-06 Thread Alberto G. Corona
Hi, After some pains, I compiled the package Network. sa_family_t is needed in network.Socket.Internal.asc and MinGW seems that it has no such variable defined. I share here the package with the compiled binaries included:

Re: [Haskell-cafe] network-2.3.0.10 compiled for ghc 7.4.1 windows

2012-02-06 Thread Johan Tibell
Hi, Someone recently contributed a fix that should make network build with 7.4: https://github.com/haskell/network/pull/25 Can you see if that works for you? I haven't yet had time to merge and release that fix (I'm on vacation.) -- Johan ___

[Haskell-cafe] Google Summer of Code 2012 Announced

2012-02-06 Thread Johan Tibell
Hi all, Here's a heads-up that this year's Google of Code is kicking off. My experience from the last few years is that we can maximize the output we get from GSoC by being proactive and writing down semi-detailed explanations of what kind of projects we'd like to see, instead of letting the

Re: [Haskell-cafe] ANNOUNCE: system-filepath 0.4.5 and system-fileio 0.3.4

2012-02-06 Thread Joey Hess
John Millikin wrote: Perhaps I'm misunderstanding, but the definition of 'withFilePath' you provided is definitely locale-dependent. Unless getFileSystemEncoding is constant? I think/hope it's locale dependent, but undecodable bytes are remapped, so as long as the system's locale doesn't

Re: [Haskell-cafe] Contributing to http-conduit

2012-02-06 Thread Myles C. Maxfield
After all these commits have been flying around, I have yet another question: the 'HTTP' package defines Network.Browser which is a State monad which keeps state about a browser (i.e. a cookie jar, a proxy, redirection parameters, etc.) It would be pretty straightforward to implement this kind of

Re: [Haskell-cafe] Contributing to http-conduit

2012-02-06 Thread Aristid Breitkreuz
I would say: if it adds no package dependencies, put it right in. Aristid Am 06.02.2012 22:09 schrieb Myles C. Maxfield myles.maxfi...@gmail.com: After all these commits have been flying around, I have yet another question: the 'HTTP' package defines Network.Browser which is a State monad

Re: [Haskell-cafe] ghc-api Static Semantics?

2012-02-06 Thread JP Moresmau
As a side note, buildwrapper version 0.4.0 and above follows the approach you outline. When a file is modified, we call GHC to build it, and we store the GHC AST as a JSON object in a hidden file. Then all subsequent calls that make use of the JSON data (in EclipseFP, this would be to show you a

[Haskell-cafe] Evaluating parallel computations in order of finishing (approximately)

2012-02-06 Thread Victor Miller
Suppose that we have a list [a] of computations that we want to evaluate in parallel. I would like to have something (probably a monad) which would return the list in order (roughly) of finishing: Say the monad is M. It would be something like the state monad, in that it would be implemented by

Re: [Haskell-cafe] Google Summer of Code 2012 Announced

2012-02-06 Thread Rogan Creswick
On Mon, Feb 6, 2012 at 12:54 PM, Johan Tibell johan.tib...@gmail.com wrote:  2. Advertise the projects on haskell-cafe, reddit, twitter, Google+ Does anyone know if the GSOC trac is in use this year? (or will be?). I started advocating for an extension to cabal to specify Setup.hs build

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Jason Dagit
On Mon, Feb 6, 2012 at 12:00 PM, Clark Gaebel cgae...@csclub.uwaterloo.ca wrote: Using the OpenGL package on Hackage, how do I load a texture from an array? The answer will depend on a few things: * Which OpenGL package you use, for example OpenGL vs. OpenGLRaw * What type of 'array' you

Re: [Haskell-cafe] Evaluating parallel computations in order of finishing (approximately)

2012-02-06 Thread Edward Amsden
Conal Elliot did something like this for his FRP system in the paper Push-Pull Functional Reactive Programming [1]. It involved a hack in which unsafePerformIO was used to spawn two threads to evaluate two events for occurrences, and return whichever returned first. Recall though, that monads

[Haskell-cafe] Switching GHC Version

2012-02-06 Thread HASHIMOTO, Yusaku
Hi, I wrote a simple shell function for switching GHC version on the system. It works only under Mac OSX, and only switch GHCs installed via .pkg installers. It's useful to experiment newer features without worrying breaking environment. GHC_BASE_DIR=/Library/Frameworks/GHC.framework/Versions/

Re: [Haskell-cafe] Switching GHC Version

2012-02-06 Thread Austin Seipp
Personally I prefer just using 'virthualenv' these days, which installs copies of GHC locally that you can then activate with your shell, similar to 'virtualenv' in python. It's how I test packages on multiple copies of GHC. http://hackage.haskell.org/package/virthualenv The nicest part is that

Re: [Haskell-cafe] Switching GHC Version

2012-02-06 Thread Brandon Allbery
On Mon, Feb 6, 2012 at 18:27, HASHIMOTO, Yusaku nonow...@gmail.com wrote: Hi, I wrote a simple shell function for switching GHC version on the system. It works only under Mac OSX, and only switch GHCs installed via .pkg installers. It's useful to experiment newer features without worrying

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-02-06 Thread Richard O'Keefe
On 4/02/2012, at 12:13 AM, Gábor Lehel wrote: All of this said, record.field is still the most readable, intuitive, and familiar syntax for selecting a field from a record that I know of. Having learned COBOL and Algol 68 before Haskell was dreamed of, I regard field OF record as

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-02-06 Thread AntC
Donn Cave donn at avvanta.com writes: Quoth AntC anthony_clayden at clear.net.nz, ... We're on the slippery slope! Where will it end? And now that I've found it, I so love: customer.lastName.tail.head.toUpper-- Yay! ... compared to present practice, with where dot is

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
Thank you both. I'll be sure to try these out. As a matter of fact, I _am_ using JuicyPixels. I didn't realize there was a version on github which uses Vector. Thanks for letting me know. Regards, - clark On Mon, Feb 6, 2012 at 5:55 PM, Jason Dagit dag...@gmail.com wrote: On Mon, Feb 6,

Re: [Haskell-cafe] Switching GHC Version

2012-02-06 Thread HASHIMOTO, Yusaku
Thanks for suggestions. Having /usr/bin scripts seems to work for me, Although virthualenv looks promising for package dependency management. But when run virthualenv with --ghc=tarball, it creates copy of GHC suite inside a project whose size is about 700MB. On 2012/02/07, at 8:41, Brandon

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-02-06 Thread AntC
Richard O'Keefe ok at cs.otago.ac.nz writes: On 4/02/2012, at 12:13 AM, Gábor Lehel wrote: All of this said, record.field is still the most readable, intuitive, and familiar syntax for selecting a field from a record that I know of. Having learned COBOL and Algol 68 before

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-02-06 Thread Donn Cave
Quoth AntC anthony_clay...@clear.net.nz, ... It was a surprise to me that dot without spaces around is still legal syntax for function composition. It isn't even unusual. You can find stuff like fromIntegral.ord in packages downloaded to build cabal-install for example. It graphically appeals

[Haskell-cafe] a variant of TDNR (was: Re: Some thoughts on Type-Directed Name Resolution)

2012-02-06 Thread Evan Laforge
I brought up an idea on another thread, but it was a bit off subject and I think it got buried. Anyway, I'm curious to know if there are any obvious problems with this idea, or if it could be pursued further: It could be called Tagged Type Directed Name Resolution. The idea is a # prefix for

Re: [Haskell-cafe] Some thoughts on Type-Directed Name Resolution

2012-02-06 Thread AntC
Donn Cave donn at avvanta.com writes: You can find stuff like fromIntegral.ord in packages downloaded to build cabal-install for example. It graphically appeals to the notion of a function composed of several functions, so the programmers in question will likely not even be repentant!

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Ben Lippmeier
On 07/02/2012, at 7:00 AM, Clark Gaebel wrote: Using the OpenGL package on Hackage, how do I load a texture from an array? In the red book[1], I see their code using glGenTextures and glBindTexture, but I can't find these in the documentation. Are there different functions I should be

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
Awesome. Thanks! As a follow up question, how do I add a finalizer to a normal variable? OpenGL returns an integer handle to your texture in graphics memory, and you have to call deleteObjectNames on it. Is there any way to have this automatically run once we lose all references to this variable

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Ben Lippmeier
On 07/02/2012, at 2:40 PM, Clark Gaebel wrote: Awesome. Thanks! As a follow up question, how do I add a finalizer to a normal variable? OpenGL returns an integer handle to your texture in graphics memory, and you have to call deleteObjectNames on it. Is there any way to have this

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
I would be running the GC manually at key points to make sure it gets cleaned up. Mainly, before any scene changes when basically everything gets thrown out anyways. On Mon, Feb 6, 2012 at 10:49 PM, Ben Lippmeier b...@ouroborus.net wrote: On 07/02/2012, at 2:40 PM, Clark Gaebel wrote:

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Ben Lippmeier
On 07/02/2012, at 2:50 PM, Clark Gaebel wrote: I would be running the GC manually at key points to make sure it gets cleaned up. Mainly, before any scene changes when basically everything gets thrown out anyways. From the docs: newForeignPtr :: FinalizerPtr a - Ptr a - IO (ForeignPtr

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
Is the Haskell garbage collector conservative, or precise? If it's conservative, then this will only usually work. If it's precise, it should always work. On Mon, Feb 6, 2012 at 10:56 PM, Ben Lippmeier b...@ouroborus.net wrote: On 07/02/2012, at 2:50 PM, Clark Gaebel wrote: I would be

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Austin Seipp
It's a precise GC of course (conservative collection would be madness considering how much memory Haskell programs chew through.) That still doesn't ensure your finalizer will run during the next GC even if all the references are gone by then. Sent from my iPhone^H^H^H^H^HPortable Turing machine

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Clark Gaebel
Even the next major, manually triggered GC? I'm just dealing with GHC here, if that simplifies the discussion. Although important and good to know, I don't really care what the spec says here. I just want to know if, with the current implementation of GHC, finalizeres will be run if a GC is

Re: [Haskell-cafe] Loading a texture in OpenGL

2012-02-06 Thread Austin Seipp
Just to clarify, this guarantee possibly could be made, ghc just doesn't do it now. In the past ghc never guaranteed a finalizer would ever be run. Regardless I would be wary of trusting finalizers to clean up very scarce resources. A malloc'd buffer is probably fine to have a finalizer for,

Re: [Haskell-cafe] Contributing to http-conduit

2012-02-06 Thread Michael Snoyman
+1 On Mon, Feb 6, 2012 at 11:16 PM, Aristid Breitkreuz arist...@googlemail.com wrote: I would say: if it adds no package dependencies, put it right in. Aristid Am 06.02.2012 22:09 schrieb Myles C. Maxfield myles.maxfi...@gmail.com: After all these commits have been flying around, I have

Re: [Haskell-cafe] ANN: exists-0.1

2012-02-06 Thread Mikhail Vorozhtsov
On 02/06/2012 03:32 AM, Gábor Lehel wrote: There's a common pattern in Haskell of writing: data E where E :: C a = a - E also written data E = forall a. C a = E a I recently uploaded a package to Hackage which uses the new ConstraintKinds extension to factor this pattern out into an Exists