[Haskell-cafe] Suggestiong for inter-thread communication

2013-01-26 Thread Erik de Castro Lopo
Hi all, I am in the process of writing a Haskell program consisting of two threads, one for performing a calculation and one for an Ncurses UI (haskell-ncurses). The calculation thread needs to feed a stream of numbers back to the UI thread (about 1 value per second) and the UI needs to take

Re: [Haskell-cafe] Suggestiong for inter-thread communication

2013-01-26 Thread Thiago Negri
Do you need advice on what? I didn't understand your last phrase. Em 26/01/2013 06:25, Erik de Castro Lopo mle...@mega-nerd.com escreveu: Hi all, I am in the process of writing a Haskell program consisting of two threads, one for performing a calculation and one for an Ncurses UI

Re: [Haskell-cafe] ANN: monad-bool 0.1

2013-01-26 Thread Ertugrul Söylemez
wren ng thornton w...@freegeek.org wrote: Yes. There is no reason to put up a second Hackage for that one. Without changing anything in the current system, packages can just update their categories, so that they will be displayed below Defunct or something like that. This is fine, as

Re: [Haskell-cafe] Suggestiong for inter-thread communication

2013-01-26 Thread Vincent Hanquez
On Sat, Jan 26, 2013 at 07:46:04AM -0200, Thiago Negri wrote: Do you need advice on what? I didn't understand your last phrase. IIUC, it has to do which how to interrupt a blocking call to ncurses event handling, from another thread (the calculation thread) to let the UI thread refresh the UI

Re: [Haskell-cafe] Suggestiong for inter-thread communication

2013-01-26 Thread Erik de Castro Lopo
Thiago Negri wrote: Do you need advice on what? I didn't understand your last phrase. Well I have data from two sources, stdin and the calculation thread. If I was doing this in C, I'd probably use a pipe for the calculation data and then do select on the two file descriptors. There is a

Re: [Haskell-cafe] Suggestiong for inter-thread communication

2013-01-26 Thread Ertugrul Söylemez
Erik de Castro Lopo mle...@mega-nerd.com wrote: Do you need advice on what? I didn't understand your last phrase. Well I have data from two sources, stdin and the calculation thread. If I was doing this in C, I'd probably use a pipe for the calculation data and then do select on the two

Re: [Haskell-cafe] Suggestiong for inter-thread communication

2013-01-26 Thread Petr P
Hi Erik, there seem to be several options. Tie simplest one is that you'll call getEvent with some reasonable timeout in a loop and check some communication channel an update from the calculation thread. Probably the correct way how to handle it involves three threads: (1) The computation

[Haskell-cafe] aeson-0.6.1.0 deriveJSON error

2013-01-26 Thread jims
ghc doesn't seem to be unifying deriveJSON (String-String) parameter with id :: a - a. examples/TemplateHaskell.hs:22:14: Couldn't match expected type `Data.Aeson.TH.Options' with actual type `a0 - a0' In the first argument of `deriveJSON', namely `id' In the

Re: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error

2013-01-26 Thread Bas van Dijk
On 26 January 2013 14:47, j...@stuttard.org wrote: ghc doesn't seem to be unifying deriveJSON (String-String) parameter with id :: a - a. It seems you're using aeson HEAD. Note that the deriveJSON from the released aeson-0.6.1.0 as the type: deriveJSON :: (String - String) - Name - Q [Dec]

Re: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error

2013-01-26 Thread Bas van Dijk
On 26 January 2013 15:20, Bas van Dijk v.dijk@gmail.com wrote: But in aeson-HEAD it has the following type: deriveJSON :: Options - Name - Q [Dec] Note that I'm currently working on extending the encoding Options record: * I added a constructorNameModifier :: String - String which is

Re: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error

2013-01-26 Thread jims
Quoting Bas van Dijk v.dijk@gmail.com: On 26 January 2013 14:47, j...@stuttard.org wrote: ghc doesn't seem to be unifying deriveJSON (String-String) parameter with id :: a - a. It seems you're using aeson HEAD. Note that the deriveJSON from the released aeson-0.6.1.0 as the type:

Re: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error

2013-01-26 Thread jims
Quoting Bas van Dijk v.dijk@gmail.com: On 26 January 2013 15:20, Bas van Dijk v.dijk@gmail.com wrote: But in aeson-HEAD it has the following type: deriveJSON :: Options - Name - Q [Dec] Note that I'm currently working on extending the encoding Options record: * I added a

Re: [Haskell-cafe] Suggestiong for inter-thread communication

2013-01-26 Thread Brandon Allbery
On Sat, Jan 26, 2013 at 5:51 AM, Petr P petr@gmail.com wrote: However, I'm not sure if Ncurses doesn't mind calling getEvent from a different thread than the one that updates UI. I don't know if the Haskell bindings change this, but at the C level as long as automatic echo to a window is

[Haskell-cafe] Writing config files for configurator library

2013-01-26 Thread Daniel Austin
Hello Haskellers, What is the typical way to write out configuration files for use by the configurator library? From asking around, seems like the library does not (obviously) support writing out config files to disc from scratch. What I want to do is write out a default config file to disc, or

Re: [Haskell-cafe] How to store Fixed data type in the database with persistent ?

2013-01-26 Thread Michael Snoyman
Very nice to see, I'm happy to stand corrected here. We'll definitely get some support for fixed into the next major release. On Saturday, January 26, 2013, wrote: According to the documentation, SQLite stores whatever you give it, paying very little heed to the declared type. If you get

[Haskell-cafe] SDL and ALUT on Windows: stdin Bad file descriptor

2013-01-26 Thread Thiago Negri
I'm trying SDL on Windows, and things are getting really weird. I can compile the code (links on the end). When I run it, if I try using `stdin` the program crashes with this message: stdin: hGetLine: invalid argument (Bad file descriptor) Is it something to do with SDL itself? What am I doing

Re: [Haskell-cafe] cabal install choosing an older version

2013-01-26 Thread Simon Hengel
Hi Ozgur, I'm missing some context here, but I'll release an updated version of hspec ASAP ;) Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] catamorphisms and attribute grammars

2013-01-26 Thread Petr P
Dear Haskellers, I read some stuff about attribute grammars recently [1] and how UUAGC [2] can be used for code generation. I felt like this should be possible inside Haskell too so I did some experiments and I realized that indeed catamorphisms can be represented in such a way that they can be

Re: [Haskell-cafe] Use forM_ with Maybe, it's Foldable!

2013-01-26 Thread Felipe Almeida Lessa
Herbert Valerio actually pointed out to me in PVT that funnily enough I've actually *forgotten* and *rediscovered* this idiom! =) http://www.haskell.org/pipermail/libraries/2011-November/017257.html Cheers! On Sat, Jan 26, 2013 at 5:43 PM, Felipe Almeida Lessa felipe.le...@gmail.com wrote:

Re: [Haskell-cafe] SDL and ALUT on Windows: stdin Bad file descriptor

2013-01-26 Thread Henk-Jan van Tuyl
On Sat, 26 Jan 2013 21:52:03 +0100, Brandon Allbery allber...@gmail.com wrote: On Sat, Jan 26, 2013 at 3:34 PM, Thiago Negri evoh...@gmail.com wrote: I'm trying SDL on Windows, and things are getting really weird. I can compile the code (links on the end). When I run it, if I try using

Re: [Haskell-cafe] catamorphisms and attribute grammars

2013-01-26 Thread Roman Cheplyaka
* Petr P petr@gmail.com [2013-01-26 23:03:51+0100] Dear Haskellers, I read some stuff about attribute grammars recently [1] and how UUAGC [2] can be used for code generation. I felt like this should be possible inside Haskell too so I did some experiments and I realized that indeed

Re: [Haskell-cafe] SDL and ALUT on Windows: stdin Bad file descriptor

2013-01-26 Thread Thiago Negri
I didn't use `-optl-mwindows`. I guess the dependency on SDL is doing this. Anyway, I was trying to print some debug messages to see what was going wrong. Replaces the debugs message with on-screen messages using `SDL-ttf` package. Thanks, Thiago. 2013/1/26 Henk-Jan van Tuyl hjgt...@chello.nl

Re: [Haskell-cafe] Use forM_ with Maybe, it's Foldable!

2013-01-26 Thread John Wiegley
Felipe Almeida Lessa felipe.le...@gmail.com writes: A few days ago I decided to hoogle the type of whenJust [2] and what I discovered is that import Data.Foldable (forM_) whenJust = forM_ You can also use for_, if you want to use Applicative instead of Monad. -- John Wiegley FP

Re: [Haskell-cafe] How to store Fixed data type in the database with persistent ?

2013-01-26 Thread alexander . vershilov
Sat, Jan 26, 2013 at 12:21:02PM +0600, s9gf4...@gmail.com wrote According to the documentation, SQLite stores whatever you give it, paying very little heed to the declared type. If you get SQLite to *compare* two numbers, it will at that point *convert* them to doubles in order to carry

Re: [Haskell-cafe] catamorphisms and attribute grammars

2013-01-26 Thread Chris Wong
Hi Petr, Congratulations -- you've just implemented a Moore machine! [1] I posted something very much like this just last year [2]. It's a very common pattern in Haskell, forming the basis of coroutines and iteratees and many other things. Edward Kmett includes it in his machines package [3].

Re: [Haskell-cafe] catamorphisms and attribute grammars

2013-01-26 Thread Roman Cheplyaka
Hi Chris, While the two things solve similar problems and have other similarities, they are still quite different. It's hard to call Petr's type a machine — there's no dynamics in it. It's just a pair of an f-algebra and finalizer. Values of your type return themselves — it is exactly this