Re: [Haskell-cafe] Where is the pairing-with-monoid monad instance?

2012-01-11 Thread Sean Leather
On Wed, Jan 11, 2012 at 03:23, Conal Elliott wrote: Is the standard pair-with-monoid monad instance in some standard place? I see the Applicative instance in Control.Applicative, and the pair-with-monoid Functor instance in Control.Monad.Instances, and the (-) e and Either e monad instances

Re: [Haskell-cafe] GHC exceeding command line length limit with split-objs - and a possible fix

2012-01-11 Thread John Lato
I used https://github.com/kennethreitz/osx-gcc-installer/downloads to get a real gcc on Lion. Biggish download, but it worked. I've also seen reports of success by self-compiling gcc, or by installing XCode 4 on top of an existing XCode 3 installation. John L. From: Eugene Kirpichov

Re: [Haskell-cafe] GHC exceeding command line length limit with split-objs - and a possible fix

2012-01-11 Thread Hans Aberg
On 11 Jan 2012, at 13:38, John Lato wrote: I used https://github.com/kennethreitz/osx-gcc-installer/downloads to get a real gcc on Lion. Biggish download, but it worked. I've also seen reports of success by self-compiling gcc, or by installing XCode 4 on top of an existing XCode 3

Re: [Haskell-cafe] GHC exceeding command line length limit with split-objs - and a possible fix

2012-01-11 Thread Eugene Kirpichov
Thanks, looks like I already succeeded by downloading xcode 3. Now my original question remains - is such a change a good idea? (I've already found the place in code where the fix has to be made; should take an hour of work at most) On Wed, Jan 11, 2012 at 6:07 PM, Hans Aberg haber...@telia.com

Re: [Haskell-cafe] GHC exceeding command line length limit with split-objs - and a possible fix

2012-01-11 Thread Ozgur Akgun
Hi Eugene, I think I did run into this problem before, and had to turn of split-objs temporarily to work around it. I'd appreciate a fix. Best, Ozgur On 11 January 2012 14:14, Eugene Kirpichov ekirpic...@gmail.com wrote: Now my original question remains - is such a change a good idea? (I've

Re: [Haskell-cafe] Code generation and optimisation for compiling Haskell

2012-01-11 Thread Thomas Schilling
Based on your stated background, the best start would be the (longer) paper on the Spineless Tagless G-machine [1]. It describes how graph reduction is actually implemented efficiently. Since then there have been two major changes to this basic implementation: Use of eval/apply (a different

[Haskell-cafe] Unboxed Rationals?

2012-01-11 Thread Victor Miller
I have a program which does a lot of computations with Array's of rationals. In order to get better performance I'd like to use unboxed arrays, but, since (Ratio Int) isn't a primitive type this doesn't work. It occured to me that I could rewrite this using -fglasgow-exts where I represent a

Re: [Haskell-cafe] Unboxed Rationals?

2012-01-11 Thread Artyom Kazak
You can use Data.Vector.Unboxed. There isn't an instance for Ratio a, but it is easy to write one, since it would be very similar to Complex a. http://hackage.haskell.org/packages/archive/vector/0.9.1/doc/html/Data-Vector-Unboxed.html#t:Unbox ___

Re: [Haskell-cafe] Unboxed Rationals?

2012-01-11 Thread Artyom Kazak
Also, uvector already supports unboxed Ratios: http://hackage.haskell.org/package/uvector In fact, I am surprised that Data.Vector doesn't have a Ratio instance, but has a Complex instance. Any ideas, why? ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] GHC exceeding command line length limit with split-objs - and a possible fix

2012-01-11 Thread Brandon Allbery
On Wed, Jan 11, 2012 at 02:12, Eugene Kirpichov ekirpic...@gmail.comwrote: I think a nice fix would be to employ gcc's ability to read options from a file - gcc @file - and write overly long option strings into temp files. What immediately occurs to me is, what if the problem (or another

Re: [Haskell-cafe] GHC exceeding command line length limit with split-objs - and a possible fix

2012-01-11 Thread Eugene Kirpichov
Hi Brandon, Thanks - looks like this would be a modification of the linking stage, splitting it into two parts: batching objects and then actually linking them. Do you think that what I originally proposed is still a good thing to have before implementing your solution? (it definitely would be

Re: [Haskell-cafe] GHC exceeding command line length limit with split-objs - and a possible fix

2012-01-11 Thread Brandon Allbery
On Wed, Jan 11, 2012 at 14:50, Eugene Kirpichov ekirpic...@gmail.comwrote: Do you think that what I originally proposed is still a good thing to have before implementing your solution? (it definitely would be for myself, as it's easier to do and I'd then quicker become able to build my

[Haskell-cafe] A simple telnet client using Conduit

2012-01-11 Thread Erik de Castro Lopo
Hi all, I've written a simple telnet client using Michael Snoyman's Conduit library and was looking for comments as to whether I'm doing it right. In particular, is my usage of a ResourceT to track a thread a good idea, necessary or waste of time. The code is here:

[Haskell-cafe] How to terminate the process group of a process created with createProcess?

2012-01-11 Thread André Scholz
Hello, (on unix) creating a process A which spawns itself a subprocess B and terminating process A before it finishes leaves process B as a process on its own. This is because terminateProcess sends the sigterm signal to the process only and not to its process group. Is there a way to

Re: [Haskell-cafe] How to terminate the process group of a process created with createProcess?

2012-01-11 Thread Brandon Allbery
On Wed, Jan 11, 2012 at 16:26, André Scholz andre.sch...@uni-bremen.dewrote: (on unix) creating a process A which spawns itself a subprocess B and terminating process A before it finishes leaves process B as a process on its own. This is because terminateProcess sends the sigterm signal to

Re: [Haskell-cafe] How to terminate the process group of a processcreated with createProcess?

2012-01-11 Thread Donn Cave
Quoth Brandon Allbery allber...@gmail.com, ... terminateProcess passes on the semantics of kill(2); on SVID-compliant (and I think POSIX.1-compliant) systems, the negative of the process group leader's process ID is used to signal the process group. Note that you may need to arrange for your

Re: [Haskell-cafe] Unboxed Rationals?

2012-01-11 Thread Roman Leshchinskiy
On 11/01/2012, at 17:00, Artyom Kazak wrote: In fact, I am surprised that Data.Vector doesn't have a Ratio instance, but has a Complex instance. Any ideas, why? Nobody has asked for it so far. Roman ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] A simple telnet client using Conduit

2012-01-11 Thread Felipe Almeida Lessa
On line 29, instead of liftIO $ do mapM_ ... runResourceT $ do ... ... why not liftIO $ mapM_ ... ... ... ? Regarding threads, you should use resourceForkIO [1] which has a quite nicer interface. So you telnet would end like: telnet :: String - Int - IO () telnet

Re: [Haskell-cafe] A simple telnet client using Conduit

2012-01-11 Thread Erik de Castro Lopo
Thanks for the input Felipe. Felipe Almeida Lessa wrote: On line 29, instead of liftIO $ do mapM_ ... runResourceT $ do Well that was because that whole block needs to run in IO. Regarding threads, you should use resourceForkIO [1] which has a quite nicer interface. I did

Re: [Haskell-cafe] A simple telnet client using Conduit

2012-01-11 Thread Erik de Castro Lopo
A new solution that drops two 'runResourceT' calls: telnet :: String - Int - IO () telnet host port = runResourceT $ do (releaseSock, hsock) - with (connectTo host $ PortNumber $ fromIntegral port) hClose liftIO $ mapM_ (\h - hSetBuffering h LineBuffering) [ stdin, stdout, hsock ]

Re: [Haskell-cafe] A simple telnet client using Conduit

2012-01-11 Thread Felipe Almeida Lessa
On Wed, Jan 11, 2012 at 10:28 PM, Erik de Castro Lopo mle...@mega-nerd.com wrote: Thanks for the input Felipe. Felipe Almeida Lessa wrote: On line 29, instead of   liftIO $ do     mapM_ ...     runResourceT $ do Well that was because that whole block needs to run in IO. My point is

Re: [Haskell-cafe] A simple telnet client using Conduit

2012-01-11 Thread Erik de Castro Lopo
Felipe Almeida Lessa wrote: What about inverting which thread gets to do what? _ - resourceForkIO $ sourceHandle hsock $$ sinkHandle stdout sourceHandle stdin $$ sinkHandle hsock release releaseSock Thats an interesting idea. Unfortunately this doesn't work correctly in that if the

[Haskell-cafe] How to catch all exceptions that could be caught?

2012-01-11 Thread Magicloud Magiclouds
Hi, With Prelude.catch, I could write catch () $ \_ - return Nothing. But with Control.Exception.catch, I must specify a type for the _. What should I do? PS: In Java document, a function declaration would tell us both the incoming args and outgoing, AND what exceptions would it throw. But it

Re: [Haskell-cafe] How to catch all exceptions that could be caught?

2012-01-11 Thread Gregory Crosswhite
On 01/12/12 13:03, Magicloud Magiclouds wrote: Hi, With Prelude.catch, I could write catch () $ \_ - return Nothing. But with Control.Exception.catch, I must specify a type for the _. What should I do? Use SomeException for the type, as it is the base of the exception hierarchy. (Although

[Haskell-cafe] decoupling type classes

2012-01-11 Thread Yin Wang
Hi all, I have an idea about type classes that I have been experimenting. It appears to be a generalization to Haskell’s type classes and seems to be doable. It seems to related the three ideas: type classes, implicit parameters, and (typed) dynamic scoping. But I don't know whether it is good or

Re: [Haskell-cafe] How to catch all exceptions that could be caught?

2012-01-11 Thread Ivan Lazar Miljenovic
On 12 January 2012 17:34, Gregory Crosswhite gcrosswh...@gmail.com wrote: On 01/12/12 13:03, Magicloud Magiclouds wrote: Hi,   With Prelude.catch, I could write catch () $ \_ - return Nothing. But with Control.Exception.catch, I must specify a type for the _. What should I do? Use

Re: [Haskell-cafe] How to catch all exceptions that could be caught?

2012-01-11 Thread Magicloud Magiclouds
Yes, that is a problem. But consider my PS in original mail, I have no idea what exception should I catch. Where could I get that information? On Thu, Jan 12, 2012 at 2:49 PM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: On 12 January 2012 17:34, Gregory Crosswhite

Re: [Haskell-cafe] How to catch all exceptions that could be caught?

2012-01-11 Thread Simon Hengel
Use SomeException for the type, as it is the base of the exception hierarchy. But it is usually recommended that you *don't* do this, as it even captures Ctrl-c invocations: I think there are situation when it is justified to catch almost all exceptions. And people do that a lot, which

Re: [Haskell-cafe] How to catch all exceptions that could be caught?

2012-01-11 Thread Gregory Crosswhite
On 01/12/12 16:49, Ivan Lazar Miljenovic wrote: But it is usually recommended that you *don't* do this, as it even captures Ctrl-c invocations: Is that true in all threads, or just in the main thread? Cheers, Greg ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] How to catch all exceptions that could be caught?

2012-01-11 Thread Gregory Crosswhite
On 01/12/12 17:07, Simon Hengel wrote: I think there are situation when it is justified to catch almost all exceptions. And people do that a lot, which often leads to ctrl-c not properly working (e.g. we had this in HUnit before 1.2.4.2). Indeed, and in fact this situation is a very natural

Re: [Haskell-cafe] How to catch all exceptions that could be caught?

2012-01-11 Thread Gregory Crosswhite
On 01/12/12 17:23, Gregory Crosswhite wrote: Indeed, and in fact this situation is a very natural occurrence whenever you are writing code that takes an arbitrary IO action, executes it, and then returns either the result or the exception that it threw. The code that I last used for this took

Re: [Haskell-cafe] How to catch all exceptions that could be caught?

2012-01-11 Thread Gregory Crosswhite
On 01/12/12 16:58, Magicloud Magiclouds wrote: Yes, that is a problem. But consider my PS in original mail, I have no idea what exception should I catch. Where could I get that information? In my experience, exceptions fall into three categories. First, when performing IO, some functions

Re: [Haskell-cafe] How to catch all exceptions that could be caught?

2012-01-11 Thread Magicloud Magiclouds
Thank you so much. I was always confused by what exception should I catch. On Thu, Jan 12, 2012 at 3:49 PM, Gregory Crosswhite gcrosswh...@gmail.com wrote: On 01/12/12 16:58, Magicloud Magiclouds wrote: Yes, that is a problem. But consider my PS in original mail, I have no idea what exception