Re: Re[Haskell-cafe] [2]: Threading and FFI

2010-02-17 Thread Yves Parès
Thank you all. But there are two things that remain obscure: First, there is my situation: int the main thread, I call to some C functions binded through FFI. All of them are marked 'unsafe', except one, which is internally supposed to make pauses with 'usleep'. I then execute in another haskell

Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-17 Thread Evan Laforge
By purest coincidence I just wrote the exact same function (the simple mergeAll', not the VIP one). Well, extensionally the same... intensionally mine is 32 complicated lines and equivalent to the 3 line mergeAll'. I even thought of short solution by thinking that pulling the first element destro

[Haskell-cafe] Re: Pointfree composition for higher arity

2010-02-17 Thread oleg
Sean Leather wrote: > (...) :: (c -> d) -> (a -> b -> c) -> a -> b -> d > (...) f g x y = f (g x y) > Does anybody else care about this? What are some alternative > solutions? Here is a different solution: http://okmij.org/ftp/Haskell/polyvariadic.html#polyvar-comp f:: a1->a2-> -

Re[2]: [Haskell-cafe] Threading and FFI

2010-02-17 Thread Bulat Ziganshin
Hello Yves, Thursday, February 18, 2010, 2:10:42 AM, you wrote: > Okay! So under UNIX, haskell threaded runtime uses pthreads, if I well > understood. not exactly. it still uses lightweight (green) threads, but starts additional OS threads as required to keep N haskell threads running. it's very

Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-17 Thread Leon Smith
On Wed, Feb 17, 2010 at 6:58 AM, Heinrich Apfelmus wrote: > Ah, I meant to use the union' from your previous message, but I think > that doesn't work because it doesn't have the crucial property that the case > >union (VIP x xs) ys = ... > > does not pattern match on the second argument. Ah

Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-17 Thread Jeremy Shaw
On Wed, Feb 17, 2010 at 3:54 PM, Jeremy Shaw wrote: > On Wed, Feb 17, 2010 at 1:27 PM, Bardur Arantsson wrote: > >> >> (Obviously, if people are using sendfile with something other than >>> happstack, >>> it does not help them, but it sounds like trying to fix things in >>> >> > sendfile is mis

Re: [Haskell-cafe] Category Theory woes

2010-02-17 Thread Nick Rudnick
I haven't seen anybody mentioning «Joy of Cats» by Adámek, Herrlich & Strecker: It is available online, and is very well-equipped with thorough explanations, examples, exercises & funny illustrations, I would say best of university lecture style: http://katmat.math.uni-bremen.de/acc/. (Actua

Re: GUI (was: Re: [Haskell-cafe] DLL on Windows)

2010-02-17 Thread Thomas DuBuisson
On Wed, Feb 17, 2010 at 3:17 AM, Jeremy O'Donoghue wrote: > You're probably correct about the dependencies. I have never tried to > compile wxHaskell against GHC 6.12.1 > > I'm waiting for Haskell Platform to be released to make the required > changes since (working primarily on Windows) I just do

Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-17 Thread Leon Smith
On Wed, Feb 17, 2010 at 6:58 AM, Heinrich Apfelmus wrote: > Ah, I meant to use the  union'  from your previous message, but I think > that doesn't work because it doesn't have the crucial property that the case > >    union (VIP x xs) ys = ... > > does not pattern match on the second argument. A

Re: [Haskell-cafe] Threading and FFI

2010-02-17 Thread Yves Parès
Okay! So under UNIX, haskell threaded runtime uses pthreads, if I well understood. To sum up, in order to achieve what I want, I have no other choice than compiling with '-threading' and importing as 'safe' the functions which can make a 'sleep'. Thanks! Ben Franksen wrote: > > Yves Parès wro

Re: [Haskell-cafe] What is the meaning of tilde ("~") symbol

2010-02-17 Thread Daniel Schüssler
On Sunday 14 February 2010 17:02:36 Henk-Jan van Tuyl wrote: > The symbols that are not specified in a library can be found here: >http://www.haskell.org/haskellwiki/Keywords > Hoogle used to show links to this page, when a keyword was searched, but > not anymore. > This isn't Haskell 98 only

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Stephen Tetley
Hi Sean Thanks for the comment. David Menendez pointed out on the other thread that they generalize nicely to functors: http://www.haskell.org/pipermail/haskell-cafe/2009-December/071428.html Typographically they are a pun on ML's composition operator (o), if you don't define o - (aka 'monocle'

Re: [Haskell-cafe] Linear programming in Haskell

2010-02-17 Thread Daniel Peebles
Interesting. Do you have any details on this? It seems like it would be hard to express system of linear inequalities as a finite system of linear equations. Thanks, Dan 2010/2/17 Matthias Görgens > > As far as I can see, you'd use that for systems of linear equalities, but > > for systems of l

[Haskell-cafe] Re: Threading and FFI

2010-02-17 Thread Ben Franksen
Yves Parès wrote: > I've also discovered something interesting: when I link with the > 'threaded' runtime, but let the program use only one core (with '+RTS > -N1'), the problem disappears. How comes? > The whole thing remains a mystery, because I think what I'm trying to do > is quite common... >

Re: [Haskell-cafe] Linear programming in Haskell

2010-02-17 Thread Erik de Castro Lopo
Alberto Ruiz wrote: > I think that GSL does not include linear programming solvers, but in the > GSL home page there is a reference to the GLPK package: > > http://www.gnu.org/software/glpk/glpk.html > > I have not used it, but it would be very nice to have a simple Haskell > interface to GLPK

Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-17 Thread Jeremy Shaw
On Wed, Feb 17, 2010 at 1:27 PM, Bardur Arantsson wrote: > > (Obviously, if people are using sendfile with something other than >> happstack, >> it does not help them, but it sounds like trying to fix things in >> > > sendfile is misguided anyway.) > >> >> > How so? As a user I expect sendfile t

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Sean Leather
On Wed, Feb 17, 2010 at 16:48, Stephen Tetley wrote: > On 17 February 2010 15:41, Mike Dillon wrote: > > That signature is the `oo` "specs" combinator in Data.Aviary: > Nice! I wouldn't recommend writing code that depends on Data.Aviary, but > some of the combinators are often worth copy/pasti

Re: [Haskell-cafe] Linear programming in Haskell

2010-02-17 Thread Matthias Görgens
> As far as I can see, you'd use that for systems of linear equalities, but > for systems of linear inequalities with a linear objective function, it's > not suitable. I may be wrong though :) There's a linear [1] reduction from one problem to the other and vice versa. [1] The transformation itse

Re: [Haskell-cafe] CURL and threads

2010-02-17 Thread Eugeny N Dzhurinsky
On Wed, Feb 17, 2010 at 07:34:07PM +0200, Eugene Dzhurinsky wrote: > Hopefully, someone could help me in overcoming my ignorance :) I realized that I can share the same Chan instance over all invocations in main, and wrap internal function into withCurlDo to ensure only one IO action gets executed

Re: [Haskell-cafe] The Related monad and constant values in type classes

2010-02-17 Thread Sean Leather
> What i want to know is if there is already > something like this (and suggestions for improvement of course). > ... > Sometimes i find myself needing to associate a constant with a type > or, more precisely, with a type class instance. > I'm not sure if this is what you're looking for, but it

[Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-17 Thread Bardur Arantsson
Jeremy Shaw wrote: On Wed, Feb 17, 2010 at 2:36 AM, Taru Karttunen wrote: So for sendfile, instead of threadWaitWrite we could do: r <- timeout (60 * 10^6) threadWaitWrite case r of Nothing -> ... -- timed out (Just ()) -> ... -- keep going For sendfile, a timeout of 1 second would

Re: [Haskell-cafe] ANN: concurrent-extra-0.1

2010-02-17 Thread Felipe Lessa
On Wed, Feb 17, 2010 at 05:11:45PM +0100, Roel van Dijk wrote: > On Wed, Feb 17, 2010 at 3:27 PM, Felipe Lessa wrote: > > In release (l. 142) Nothing is put into mv > > > >                        then do Lock.release lock > >                                putMVar mv Nothing > > I'm not sure if th

Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-17 Thread Daniel Fischer
Am Mittwoch 17 Februar 2010 18:59:42 schrieb Ozgur Akgun: > Ooops I thought the inner lists are possibly of infinite size. > Both, I think. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-17 Thread Ozgur Akgun
Ooops I thought the inner lists are possibly of infinite size. On 17 February 2010 17:16, Daniel Fischer wrote: > Am Mittwoch 17 Februar 2010 17:46:38 schrieb Ozgur Akgun: > > > The easiest solution is simply to define > > > > > >unionAll = nub . mergeAll > > >where > > >-- s

[Haskell-cafe] CURL and threads

2010-02-17 Thread Eugene Dzhurinsky
Hello, all! Can somebody please explain, what is the best way of using CURL with several threads? I wrote simple client, which tries to authenticate against HTTP server. With running this client, it starts to eat memory insanely (and I know this code is far, far away of even being close to be call

Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-17 Thread Daniel Fischer
Am Mittwoch 17 Februar 2010 17:46:38 schrieb Ozgur Akgun: > > The easiest solution is simply to define > > > >unionAll = nub . mergeAll > >where > >-- specialized definition of nub > >nub = map head . groupBy (==) > > Talking about the easiest solution, I guess this is

Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-17 Thread Jeremy Shaw
On Wed, Feb 17, 2010 at 2:36 AM, Taru Karttunen wrote: > Excerpts from Bardur Arantsson's message of Tue Feb 16 23:48:14 +0200 2010: > > > This cannot be fixed in the sendfile library, it is a > > > feature of TCP that connections may linger for a long > > > time unless explicit timeouts are used

Re: [Haskell-cafe] Re: Implementing "unionAll"

2010-02-17 Thread Ozgur Akgun
> The easiest solution is simply to define > >unionAll = nub . mergeAll >where >-- specialized definition of nub >nub = map head . groupBy (==) > > Talking about the easiest solution, I guess this is a quite easy way of defining unionAll as well: http://gist.github.com

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Mike Dillon
begin Stephen Tetley quotation: > On 17 February 2010 16:05, Mike Dillon wrote: > ... > > > Are you kidding me? I love writing code like this: > > > >    o = bunting bunting cardinal thrush blackbird > > > > :) > > Hi Mike > > Thanks! - it took me a surprising amount of time to get from thi

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Stephen Tetley
On 17 February 2010 16:05, Mike Dillon wrote: ... > Are you kidding me? I love writing code like this: > >    o = bunting bunting cardinal thrush blackbird > > :) Hi Mike Thanks! - it took me a surprising amount of time to get from this (where I cheated and used an online 'combinator calcul

Re: [Haskell-cafe] ANN: concurrent-extra-0.1

2010-02-17 Thread Roel van Dijk
On Wed, Feb 17, 2010 at 3:27 PM, Felipe Lessa wrote: > In acquire (l. 111), if the lock was already acquired it goes by > >        | otherwise   → do putMVar mv mb >                           Lock.acquire lock > > So it puts back the information about the owner of the RLock and > waits for its rel

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Mike Dillon
begin Stephen Tetley quotation: > On 17 February 2010 15:41, Mike Dillon wrote: > > That signature is the `oo` "specs" combinator in Data.Aviary: > > Hi Mike > > Thanks - indeed, I was just looking up the thread that covered them a > month or two ago: > > http://www.haskell.org/pipermail/haskel

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Daniel Fischer
Am Mittwoch 17 Februar 2010 16:31:16 schrieb Sean Leather: > I find myself often writing this pattern: > > someFun x y z = ... > > > > fun y z = runFun $ someFun someDefault y z > > > or, alternatively: > > fun y = runFun . someFun someDefault y > > > The second option approaches the ideal pointfre

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Stephen Tetley
On 17 February 2010 15:41, Mike Dillon wrote: > That signature is the `oo` "specs" combinator in Data.Aviary: Hi Mike Thanks - indeed, I was just looking up the thread that covered them a month or two ago: http://www.haskell.org/pipermail/haskell-cafe/2009-December/071392.html I wouldn't recom

[Haskell-cafe] The Related monad and constant values in type classes

2010-02-17 Thread Jonas Almström Duregård
Hi, This literate haskell file was intended to be a quick question about a problem i have been pondering, but it developed into a short presentation instead. What i want to know is if there is already something like this (and suggestions for improvement of course). >{-#LANGUAGE GeneralizedNewtype

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Mike Dillon
That signature is the `oo` "specs" combinator in Data.Aviary: > fun = runFun `oo` someFun someDefault -md begin Sean Leather quotation: > I find myself often writing this pattern: > > someFun x y z = ... > > > > fun y z = runFun $ someFun someDefault y z > > > > or, alternatively: > > fun

Re: [Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Neil Brown
Sean Leather wrote: I find myself often writing this pattern: someFun x y z = ... fun y z = runFun $ someFun someDefault y z or, alternatively: fun y = runFun . someFun someDefault y I very often write this too (wanting function composition, but with a two-argument f

[Haskell-cafe] Pointfree composition for higher arity

2010-02-17 Thread Sean Leather
I find myself often writing this pattern: someFun x y z = ... fun y z = runFun $ someFun someDefault y z > or, alternatively: fun y = runFun . someFun someDefault y > The second option approaches the ideal pointfreeness (or pointlessness if you prefer), but I'd like to go farther: (...) ::

[Haskell-cafe] Re: Heterogeneous Data Structures - Nested Pairs and functional references

2010-02-17 Thread Günther Schmidt
Hi Alex, this looks very very interesting, gimme some time to figure it. I hope you'll take questions later ... Günther Am 16.02.10 22:34, schrieb Alexander Solla: On Feb 16, 2010, at 12:48 PM, Alexander Solla wrote: (Accumulator String)s are (Accumulator value)s for any value. So you ca

Re: [Haskell-cafe] ANN: concurrent-extra-0.1

2010-02-17 Thread Felipe Lessa
Hello, Thanks for the release! On Wed, Feb 17, 2010 at 03:10:38PM +0100, Roel van Dijk wrote: > * RLock: A lock which can be acquired multiple times by the same > thread. Also known as a reentrant mutex. In acquire (l. 111), if the lock was already acquired it goes by | otherwise →

[Haskell-cafe] ANN: concurrent-extra-0.1

2010-02-17 Thread Roel van Dijk
Hello, We would like to announce the release of concurrent-extra [1]. A library which offers a few extra synchronization primitives. These primitives are found in the standard libraries of languages like Java and Python, but not in Haskell. Quick overview: * Lock: Enforce exclusive access to a r

Re: [Haskell-cafe] Lambda's

2010-02-17 Thread Andrew Smith
Hi I agree with the sentiments below. I subscribe to particular lists because of their specialism. The URL referred to had a tenuous Haskell connection, and definitely not work the bandwidth consumed. I'm having a difficult enough time trying to master Haskell without that form of diversion. Enou

[Haskell-cafe] Re: Implementing "unionAll"

2010-02-17 Thread Heinrich Apfelmus
Leon Smith wrote: > Heinrich Apfelmus wrote: >> I see no obvious deficiencies. :) Personally, I'd probably structure it like >> >> http://www.haskell.org/haskellwiki/Prime_numbers#Implicit_Heap > > This variant, based on the wiki article, is cleaner, slightly > simpler, appears to be just as

Re: GUI (was: Re: [Haskell-cafe] DLL on Windows)

2010-02-17 Thread Jeremy O'Donoghue
You're probably correct about the dependencies. I have never tried to compile wxHaskell against GHC 6.12.1 I'm waiting for Haskell Platform to be released to make the required changes since (working primarily on Windows) I just don't have time to create a complete GHC 6.12 installation with most o

Re: [Haskell-cafe] Threading and FFI

2010-02-17 Thread Yves Parès
I've also discovered something interesting: when I link with the 'threaded' runtime, but let the program use only one core (with '+RTS -N1'), the problem disappears. How comes? The whole thing remains a mystery, because I think what I'm trying to do is quite common... Yves Parès wrote: > > Ther

Re: [Haskell-cafe] RFC: concurrent-extra

2010-02-17 Thread Roel van Dijk
2010/2/17 Neil Brown : > You don't need to do use ThreadId: MVar has an Eq instance, so you could > make your Lock type derive an Eq instance, and then you can just compare the > Locks to remove it after the timeout occurs (e.g. using delete to take it > out of the list; it should be quite near the

Re: [Haskell-cafe] RFC: concurrent-extra

2010-02-17 Thread Neil Brown
Roel van Dijk wrote: 2010/2/16 Neil Brown : I had a look at the code for Event (both versions) and Lock (but not the others just yet) and it seemed fine. If you do lots of calls to waitTimeout before a set you will accumulate old locks in the list, but that won't cause any error that I can s

[Haskell-cafe] Re: RFC: concurrent-extra

2010-02-17 Thread Roel van Dijk
2010/2/16 Simon Marlow : > You might want to take a look at the concurrency part of the GHC test suite: > > http://darcs.haskell.org/testsuite/tests/ghc-regress/concurrent/should_run/ > > Not that we've really solved the problem you're talking about, but you might > get some ideas. The method of t

[Haskell-cafe] Example for RVarT?

2010-02-17 Thread Kemps-Benedix, Torsten
Hello folks, is there an example (simpe or not) for the use of Data.Random.RVarT with an underlying monad other than Identity, e.g. StateT, ReaderT etc.? Thx Torsten ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman

Re: [Haskell-cafe] RFC: concurrent-extra

2010-02-17 Thread Roel van Dijk
2010/2/16 Neil Brown : > I had a look at the code for Event (both versions) and Lock (but not the > others just yet) and it seemed fine.  If you do lots of calls to waitTimeout > before a set you will accumulate old locks in the list, but that won't cause > any error that I can see, so it would onl

Re: [Haskell-cafe] Linear programming in Haskell

2010-02-17 Thread Alberto Ruiz
I think that GSL does not include linear programming solvers, but in the GSL home page there is a reference to the GLPK package: http://www.gnu.org/software/glpk/glpk.html I have not used it, but it would be very nice to have a simple Haskell interface to GLPK (or other similar library) in hma

Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-17 Thread Taru Karttunen
Excerpts from Bardur Arantsson's message of Tue Feb 16 23:48:14 +0200 2010: > > This cannot be fixed in the sendfile library, it is a > > feature of TCP that connections may linger for a long > > time unless explicit timeouts are used. > > The problem is that the sendfile library *doesn't* wake >