[Haskell-cafe] What are free Monads?

2010-02-27 Thread Günther Schmidt
Hello, I see the term free monad quite a lot, but don't really see an explanation what a free monad is. What sets a monad free and why in this day and age are there unfree monads? Günther ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] What are free Monads?

2010-02-27 Thread Daniel Peebles
Given any functor you can get a monad for free! data Free f a = Either a (f (Free f a)) Not sure about unfree, but there are cofree comonads that are pretty closely related, and give you a comonad given a functor: data Cofree f a = (a, f (Cofree f a)) I'm sure the more categorically minded can

[Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread zaxis
xxxMain = do timeout - getEnv xxx_TIMEOUT case timeout of Just str | [(t, _)] - reads str - do addTimeout t (hPutStrLn stderr *** TIMEOUT _exit 1) return () _ - return () ... What does the `|` mean in Just str | [(t, _)] - reads str ? Is it a

Re: [Haskell-cafe] What are free Monads?

2010-02-27 Thread Günther Schmidt
Hello Daniel, that looks lovely, but it doesn't help me much :) Günther Am 27.02.10 10:06, schrieb Daniel Peebles: Given any functor you can get a monad for free! data Free f a = Either a (f (Free f a)) Not sure about unfree, but there are cofree comonads that are pretty closely related,

Re: [Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread Lee Duhem
On Sat, Feb 27, 2010 at 5:07 PM, zaxis z_a...@163.com wrote: xxxMain = do    timeout - getEnv xxx_TIMEOUT    case timeout of        Just str | [(t, _)] - reads str - do            addTimeout t (hPutStrLn stderr *** TIMEOUT _exit 1)            return ()        _ - return () ... What

Re: [Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread Brandon S. Allbery KF8NH
On Feb 27, 2010, at 04:07 , zaxis wrote: xxxMain = do timeout - getEnv xxx_TIMEOUT case timeout of Just str | [(t, _)] - reads str - do addTimeout t (hPutStrLn stderr *** TIMEOUT _exit 1) return () _ - return () ... What does the `|` mean in Just

Re: [Haskell-cafe] What are free Monads?

2010-02-27 Thread Dan Doel
On Saturday 27 February 2010 3:54:25 am Günther Schmidt wrote: I see the term free monad quite a lot, but don't really see an explanation what a free monad is. What sets a monad free and why in this day and age are there unfree monads? Free structures originate (I think) in algebra. There

[Haskell-cafe] Re: Generalizing nested list comprehensions

2010-02-27 Thread Heinrich Apfelmus
Daniel Fischer wrote: Ishaaq Chandy wrote: If this question sounds a bit noob-ish, that would be because I am one - so apologies in advance! I have functions that look something like these: f1 :: [a] - [b] f1 xs = [foo [x1, x2] | x1 - xs, x2 - bar x1, baz x1 /= baz x2]

[Haskell-cafe] Re: What are free Monads?

2010-02-27 Thread Heinrich Apfelmus
Günther Schmidt wrote: Daniel Peebles wrote: Given any functor you can get a monad for free! data Free f a = Either a (f (Free f a)) that looks lovely, but it doesn't help me much :) Alas, that you get one for free is not the reason why it's called the free monad. Rather, for algebraic

Re: [Haskell-cafe] Testing and module export lists

2010-02-27 Thread Ivan Miljenovic
On 27 February 2010 04:44, Brandon S. Allbery KF8NH allb...@ece.cmu.edu wrote: As I read that, the leading underscore doesn't export anything; it just suppresses any unused warning for the symbol (which is consistent with the other uses of leading underscore in warnings; it's also consistent

[Haskell-cafe] Cabal pre-compiled packages

2010-02-27 Thread Diego Souza
Hi, currently when one install a cabal package it compiles it and then install generated binaries. I wonder whether or not it would be useful to have pre-compiled binaries as many package managers usually do (e.g. apt). I often think that would save some time on the expense of a busier hackage

Re: [Haskell-cafe] Cabal pre-compiled packages

2010-02-27 Thread Andrew Coppin
Diego Souza wrote: Hi, currently when one install a cabal package it compiles it and then install generated binaries. I wonder whether or not it would be useful to have pre-compiled binaries as many package managers usually do (e.g. apt). I often think that would save some time on the

Re: [Haskell-cafe] Cabal pre-compiled packages

2010-02-27 Thread Daniel Fischer
Am Samstag 27 Februar 2010 16:39:27 schrieb Andrew Coppin: Diego Souza wrote: Hi, currently when one install a cabal package it compiles it and then install generated binaries. I wonder whether or not it would be useful to have pre-compiled binaries as many package managers usually do

[Haskell-cafe] listing mountpoints and getting their properties in Haskell

2010-02-27 Thread Eugene Dzhurinsky
Hello! I need to list all currently mounted filesystems and get some stats like total space, free space, mount point and physical device. Is there any library capable of obtaining such information from OS itself? Parsing output of 'df' is locale-dependent and error-prone (because of locale

Re: [Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread Ben Millwood
On Sat, Feb 27, 2010 at 9:29 AM, Brandon S. Allbery KF8NH allb...@ece.cmu.edu wrote: On Feb 27, 2010, at 04:07 , zaxis wrote: xxxMain = do   timeout - getEnv xxx_TIMEOUT   case timeout of       Just str | [(t, _)] - reads str - do           addTimeout t (hPutStrLn stderr *** TIMEOUT _exit

Re: [Haskell-cafe] save/restore of STRef state

2010-02-27 Thread Andrew Coppin
Job Vranish wrote: I was using STRefs the other day and I ran across a case where I really wanted the ability to save the state of all my references, execute some action, and then restore the state later if needed. I didn't find anything that does this on hackage so I implemented a small

Re: [Haskell-cafe] listing mountpoints and getting their properties in Haskell

2010-02-27 Thread Andrew Coppin
Eugene Dzhurinsky wrote: Hello! I need to list all currently mounted filesystems and get some stats like total space, free space, mount point and physical device. Is there any library capable of obtaining such information from OS itself? Parsing output of 'df' is locale-dependent and

Re: [Haskell-cafe] save/restore of STRef state

2010-02-27 Thread Job Vranish
On Sat, Feb 27, 2010 at 11:53 AM, Andrew Coppin andrewcop...@btinternet.com wrote: If you use something like the State or Reader monad, it becomes trivial to temporarily modify the carried state. But maybe something like this is occasionally useful. (In particular, it seems to allow you to

[Haskell-cafe] Re: listing mountpoints and getting their properties in Haskell

2010-02-27 Thread Achim Schneider
Eugene Dzhurinsky b...@redwerk.com wrote: Hello! I need to list all currently mounted filesystems and get some stats like total space, free space, mount point and physical device. Is there any library capable of obtaining such information from OS itself? Parsing output of 'df' is

Re: [Haskell-cafe] save/restore of STRef state

2010-02-27 Thread Andrew Coppin
Job Vranish wrote: On Sat, Feb 27, 2010 at 11:53 AM, Andrew Coppin andrewcop...@btinternet.com mailto:andrewcop...@btinternet.com wrote: Why an IORef? Why not an STRef? Then you won't need unsafeIOToST. (And since the type system forces a ContextRef to exist in only one state

[Haskell-cafe] View patterns

2010-02-27 Thread Andrew Coppin
One somewhat neat thing about Haskell is that you can say case list of [[x], [y,_], [z,_,_]] - x + y + z _ - 0 In Java, you'd have to write something like if (list.length() == 3) { List t1 = list.at(0); if (t1.length() == 1) { int x = t1.at(0); List t2 = list.at(1);

Re: [Haskell-cafe] View patterns

2010-02-27 Thread Ozgur Akgun
A humble suggestion: Have a *lazy* to list method for your *lists, arrays, sets, etc.* and use the nice list-only version. On 27 February 2010 18:11, Andrew Coppin andrewcop...@btinternet.comwrote: One somewhat neat thing about Haskell is that you can say case list of [[x], [y,_],

Re: [Haskell-cafe] View patterns

2010-02-27 Thread Andrew Coppin
Ozgur Akgun wrote: A humble suggestion: Have a *lazy* to list method for your /lists, arrays, sets, etc./ and use the nice list-only version. Yeah, that works quite nicely. It won't work for arbitrarily complex structures, however. My main point was that if you make the constructors abstract

[Haskell-cafe] passing cpp options to c2hs from cabal

2010-02-27 Thread Chris Casinghino
Hi all, I have a question about cpp, c2hs and cabal. The short version: What can I put in my cabal file to get -cppopts=-U__BLOCKS__ passed as an argument in calls to c2hs? Longer story: I need to set up my cabal file so that c2hs gets this extra option to make things build smoothly on some

Re: [Haskell-cafe] passing cpp options to c2hs from cabal

2010-02-27 Thread Daniel Fischer
Am Samstag 27 Februar 2010 21:27:27 schrieb Chris Casinghino: Hi all, I have a question about cpp, c2hs and cabal. The short version: What can I put in my cabal file to get -cppopts=-U__BLOCKS__ passed as an argument in calls to c2hs? Maybe cc-options: -U__BLOCKS__ is worth a try.

[Haskell-cafe] Re: View patterns

2010-02-27 Thread Achim Schneider
Andrew Coppin andrewcop...@btinternet.com wrote: Ozgur Akgun wrote: A humble suggestion: Have a *lazy* to list method for your /lists, arrays, sets, etc./ and use the nice list-only version. Yeah, that works quite nicely. It won't work for arbitrarily complex structures, however. My

[Haskell-cafe] redirecting ghc (as a library) output

2010-02-27 Thread Martin Hilbig
hi, i'm writing a Haskell View Server for CouchDB. it communicates with couchdb over stdin and stdout. it gets JSON encoded haskell code, compiles it (like on http://www.haskell.org/haskellwiki/GHC/As_a_library), gets values, runs the given code over the given values and writes the results

Re: [Haskell-cafe] listing mountpoints and getting their properties in Haskell

2010-02-27 Thread Vasyl Pasternak
Eugene, The only Linux function that can do this is `statvfs`. But binding to it weren't implemented in the current libraries. Year ago I implemented function that queries free size of the mounted filesystem. The file is attached. To get other parameters you should only extend `peek` function of

Re: [Haskell-cafe] listing mountpoints and getting their properties in Haskell

2010-02-27 Thread Brandon S. Allbery KF8NH
On Feb 27, 2010, at 11:47 , Eugene Dzhurinsky wrote: Is there any library capable of obtaining such information from OS itself? Parsing output of 'df' is locale-dependent and error-prone (because of locale settings, output settings etc). I don't know of any Haskell bindings offhand, but

Re: [Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread zaxis
Then can i change it to : case timeout of Just str - do [(t, _)] - reads str addTimeout t (hPutStrLn stderr *** TIMEOUT _exit 1) return () _ - return () Sincerely! Brandon S. Allbery KF8NH wrote: On Feb 27, 2010, at 04:07 , zaxis wrote:

Re: [Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread Daniel Fischer
Am Sonntag 28 Februar 2010 02:08:18 schrieb zaxis: Then can i change it to : case timeout of Just str - do [(t, _)] - reads str addTimeout t (hPutStrLn stderr *** TIMEOUT _exit 1) return () _ - return () Sincerely! No. The | [(t,_)] -

Re: [Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread Felipe Lessa
On Sat, Feb 27, 2010 at 05:08:18PM -0800, zaxis wrote: Then can i change it to : case timeout of Just str - do [(t, _)] - reads str addTimeout t (hPutStrLn stderr *** TIMEOUT _exit 1) return () _ - return () No, that's different. You

[Haskell-cafe] native threads vs. -threaded

2010-02-27 Thread Donn Cave
I've sketched out a Haskell interface to a C++ toolkit that uses threads. It's the Haiku (BeOS) platform API (BeOS is an obscure OS from the '90s, Haiku is a pretty faithful recent open source re-implementation.) The API is fairly obvious and I imagine much like others that support windowed

Re: [Haskell-cafe] How to understand `|` in this code snippet ?

2010-02-27 Thread zaxis
thanks! case timeout of Just str - case reads str of [(t,_)] - addtimeout (hPutStrLn stderr *** TIMEOUT _exit 1) _ - return () _ - return () is VERY clear! Daniel Fischer-4 wrote: Am Sonntag 28 Februar 2010 02:08:18 schrieb zaxis: Then can i change it to : case

Re: [Haskell-cafe] EDSL's using Filet-O-Fish of Barrelfish project

2010-02-27 Thread C K Kashyap
Thanks, I'll follow your suggestion and get back with any doubts that I might have. Regards, Kashyap On Sat, Feb 27, 2010 at 1:37 AM, Pierre-Evariste Dagand pedag...@gmail.comwrote: Hi Kashyap, What would be your recommendation on how to get a grasp of FoF Well, you can read the PLOS paper

[Haskell-cafe] Real-time garbage collection for Haskell

2010-02-27 Thread Luke Palmer
I have seen some proposals around here for SoC projects and other things to try to improve the latency of GHC's garbage collector. I'm currently developing a game in Haskell, and even 100ms pauses are unacceptable for a real-time game. I'm calling out to people who have seen or made such