Re: [Haskell-cafe] Re: Beginner: IORef constructor?

2006-12-06 Thread Benjamin Franksen
On Wednesday 06 December 2006 07:40, Bernie Pope wrote: On 05/12/2006, at 1:00 PM, Benjamin Franksen wrote: Bernie Pope wrote: If you want a global variable then you can use something like: import System.IO.Unsafe (unsafePerformIO) global = unsafePerformIO (newIORef [])

[Haskell-cafe] Re: (a - [b]) - [a - b] ?

2006-12-06 Thread apfelmus
while pondering over the four fours problem, I wondered: Is there a function of type (a - [b]) - [a - b] It looks a bit like sequence when applied in the ((-) a) Monad: sequence :: [a - b] - a - [b] but I was looking for the other direction. I came up with: \g - map

Re: [Haskell-cafe] state updates and efficiency

2006-12-06 Thread Chris Kuklewicz
I'll make a random comment... Tim Newsham wrote: I am writing some code with complex nested state. I have a question about performance with respect to the State monad and the Reader monad. A side comment is this code: instance MonadReader s (State s) where ask = get local f m = fmap

Re: [Haskell-cafe] non-blocking Socket

2006-12-06 Thread Ian Lynagh
On Mon, Nov 13, 2006 at 12:44:05PM -0800, Donn Cave wrote: Threads, maybe? Is blocking I/O seriously incompatible with the GHC threading model (or one of the models)? The problem is that a blocking IO call would block all threads. We could execute all such calls in their own OS thread, but

[Haskell-cafe] Re: File locked unnecessarily

2006-12-06 Thread Arie Peterson
Ian Lynagh wrote: Does anyone know what could cause this locking and/or how to prevent it? Nothing else springs to mind. Are you able to send an example that shows the problem? (obviously the smaller the example, the better). I'll try to cut down the offending program to a workable size.

Re: [Haskell-cafe] state updates and efficiency

2006-12-06 Thread Tim Newsham
I'll make a random comment... Thanks for the comments! instance MonadReader s (State s) where ask = get local f m = fmap (fst . runState m . f) get ahh, hadn't thought of doing that. You want performance but this pushes more work to the compiler. If this were all functional instead

[Haskell-cafe] Would someone explain this code to me?

2006-12-06 Thread Justin Bailey
I'm reading Chris Okasaki's Purely Functional Data Structures, and some of his Haskell is confusing me. He defines the type Color and RedBlackSet as: data Color = R | B data RedBlackSet a = E | T Color (RedBlackSet a) a (RedBlackSet a) and then later he defines a function insertSet:

[Haskell-cafe] Re: Would someone explain this code to me?

2006-12-06 Thread Jón Fairbairn
Justin Bailey [EMAIL PROTECTED] writes: I'm reading Chris Okasaki's Purely Functional Data Structures, and some of his Haskell is confusing me. He defines the type Color and RedBlackSet as: data Color = R | B data RedBlackSet a = E | T Color (RedBlackSet a) a (RedBlackSet a) and

Re: [Haskell-cafe] Re: Would someone explain this code to me?

2006-12-06 Thread Justin Bailey
On 06 Dec 2006 19:33:51 +, Jón Fairbairn [EMAIL PROTECTED] wrote: and in the where statement: T _ a y b = ins s Here it's a pattern match. So if ins s returns (T x a' y' b'), then a = a'; y = y'; b = b' are used in the expresion covered by the where clause. Great, thanks

[Haskell-cafe] Re: Would someone explain this code to me?

2006-12-06 Thread Matthew Brecknell
What I don't understand is his use of the T constructor, both at insertSet x s = T B a y b Here it creates a new RedBlackSet and in the where statement: T _ a y b = ins s Here it's a pattern match. So if ins s returns (T x a' y' b'), then a = a'; y = y'; b =

[Haskell-cafe] GADTs vs arrows/typeclasses

2006-12-06 Thread S. Alexander Jacobson
I don't think I'm the only one confused here. Henrik Nilson in his paper on adding GADTs to Yampa comments that: However, the recent addition of Generalized Algebraic Data Types (GADTs) [26] to the list of Haskell extensions supported by the Glasgow Haskell Compiler (GHC) gives

Re: [Haskell-cafe] Re: File locked unnecessarily

2006-12-06 Thread Vyacheslav Akhmechet
Yes. I've run into similar issues with hs-plugins (albeit not the same). What platform are you running on? How are you compiling your code? Try compiling it with the -threaded flag and see if it fixes your problem. On 12/6/06, Arie Peterson [EMAIL PROTECTED] wrote: Ian Lynagh wrote: Does

Re: [Haskell-cafe] Would someone explain this code to me?

2006-12-06 Thread Brandon Moore
Justin Bailey wrote: I'm reading Chris Okasaki's Purely Functional Data Structures, and some of his Haskell is confusing me. He defines the type Color and RedBlackSet as: data Color = R | B data RedBlackSet a = E | T Color (RedBlackSet a) a (RedBlackSet a) and then later he defines a

Re: [Haskell-cafe] GADTs vs arrows/typeclasses

2006-12-06 Thread Daniel McAllansmith
On Thursday 07 December 2006 09:44, S. Alexander Jacobson wrote: I guess I'm also not sure what belongs in a GADT and what belongs in a typeclass e.g. here is an Arrow GADT data Arrow b c where Arr::(b-c) - Arrow b c Compose::Arrow b c - Arrow c d - Arrow b d First::Arrow

[Haskell-cafe] Re: Typeclass question

2006-12-06 Thread Benjamin Franksen
Stefan O'Rear wrote: [...] Unfortunately, it turns out that allowing foralls inside function arguments makes typechecking much harder, in general impossible. Just a tiny correction: AFAIK, it is type /inference/ which becomes undecidable in the presence of higher rank types -- checking works

[Haskell-cafe] Re: GADTs vs arrows/typeclasses

2006-12-06 Thread Arie Peterson
Hi Alex, S. Alexander Jacobson wrote: I guess I'm also not sure what belongs in a GADT and what belongs in a typeclass e.g. here is an Arrow GADT data Arrow b c where Arr::(b-c) - Arrow b c Compose::Arrow b c - Arrow c d - Arrow b d First::Arrow a b - Arrow (a,c) (b,c)

[Haskell-cafe] Re: File locked unnecessarily

2006-12-06 Thread Arie Peterson
Vyacheslav Akhmechet wrote: Yes. I've run into similar issues with hs-plugins (albeit not the same). What platform are you running on? How are you compiling your code? Try compiling it with the -threaded flag and see if it fixes your problem. My platform is amd64 (x86_64). I usually compile

Re: [Haskell-cafe] GADTs vs arrows/typeclasses

2006-12-06 Thread Henrik Nilsson
Dear all, S. Alexander Jacobson wrote: I don't think I'm the only one confused here. Henrik Nilson in his paper on adding GADTs to Yampa comments that: ... In particular, GADTs are just what is needed to address the problem discussed above since the key idea is to allow constructors

[Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-06 Thread Donald Bruce Stewart
I'd like some more help from the editors in getting 2d layout right without trying. Here's a mockup of vim with vertical grey bars delimiting layout: http://www.cse.unsw.edu.au/~dons/tmp/haskell+boxes.png Does anyone know how to get this effect in vim (or emacs)? Bonus points if the grey

Re: [Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-06 Thread Donald Bruce Stewart
dons: I'd like some more help from the editors in getting 2d layout right without trying. Here's a mockup of vim with vertical grey bars delimiting layout: http://www.cse.unsw.edu.au/~dons/tmp/haskell+boxes.png Does anyone know how to get this effect in vim (or emacs)? Bonus points

Re: [Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-06 Thread John Meacham
On Thu, Dec 07, 2006 at 11:34:42AM +1100, Donald Bruce Stewart wrote: I'd like some more help from the editors in getting 2d layout right without trying. Here's a mockup of vim with vertical grey bars delimiting layout: http://www.cse.unsw.edu.au/~dons/tmp/haskell+boxes.png Does

Re: [Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-06 Thread Carl Witty
On Wed, 2006-12-06 at 16:56 -0800, John Meacham wrote: Having played with haskell parsers for various reasons, the layout rule is quite tricky due to the rules involving 'parse-error'. if we could come up with a formulation that didn't have those. it would make things a whole lot nicer.

Re: [Haskell-cafe] WANTED: grey line layout boxes in vim and emacs

2006-12-06 Thread John Meacham
On Wed, Dec 06, 2006 at 05:37:01PM -0800, Carl Witty wrote: On Wed, 2006-12-06 at 16:56 -0800, John Meacham wrote: Having played with haskell parsers for various reasons, the layout rule is quite tricky due to the rules involving 'parse-error'. if we could come up with a formulation that

[Haskell-cafe] Re: [Haskell] Defining Cg, HLSL style vectors in Haskell

2006-12-06 Thread Fco . Javier Loma
Slavomir Kaslev slavomir.kaslev at gmail.com writes: On 11/29/06, Krasimir Angelov kr.angelov at gmail.com wrote: It is possible of course but your definition doesn't correspond to any operation in the usual vector algebra. By the way how do you define (*)? Isn't it 3D vector