[Haskell-cafe] What is the surefire way to handle all exceptions and make sure the program doesn't fail?

2012-07-17 Thread Yifan Yu
First of all, apologise if the question is too broad. The background goes like this: I've implemented a server program in Haskell for my company intended to replace the previous one written in C which crashes a lot (and btw the technology of the company is exclusively C-based). When I chose

[Haskell-cafe] Haskell's type inference considered harmful [Re: [Haskell] A riddle...]

2012-07-17 Thread Andreas Abel
[Is Haskell-Cafe the right place to discuss DESIGN issues of the Haskell language? This message is not about a concrete problem...] Congratulations to all that solved the riddle so quickly. (First answer in only 8 Minutes!) Now to the point of the exercise: Shocking realizations. 1.

Re: [Haskell-cafe] Haskell's type inference considered harmful [Re: [Haskell] A riddle...]

2012-07-17 Thread Christopher Done
On 17 July 2012 09:27, Andreas Abel andreas.a...@ifi.lmu.de wrote: 1. Haskell's type inference is NON-COMPOSITIONAL! In the riddle below, I am defining two things f (rgbliste) and g (farbliste). Even though they are not strongly connected, but g comes after f in the definition order, the

[Haskell-cafe] Non-greedy match in Text.Regx.Posix

2012-07-17 Thread C K Kashyap
Hi all, I was exploring Text.Regex.Posix and found that I was not able to do a non-greedy match by modifying the quantifier with a ?. How can I achieve non-greedy match in Text.Regex.Posix? Regards, Kashyap ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Haskell's type inference considered harmful [Re: [Haskell] A riddle...]

2012-07-17 Thread Lyndon Maydwell
You will be warned about the top-level definitions not including a type-signature if you use the -Wall flag. This isn't really a complete solution to your gripes, but it does address the change in behaviour that you saw when adding/removing the commented code, and would draw your attention to the

Re: [Haskell-cafe] Haskell's type inference considered harmful

2012-07-17 Thread oleg
1. Haskell's type inference is NON-COMPOSITIONAL! Yes, it is -- and there are many examples of it. Here is an example which has nothing to do with MonomorphismRestriction or numeric literals {-# LANGUAGE ExtendedDefaultRules #-} class C a where m :: a - Int instance C () where m _

Re: [Haskell-cafe] Haskell's type inference considered harmful

2012-07-17 Thread MigMit
Actually, both examples show that the problem isn't type inference, it's defaulting mechanism. Отправлено с iPhone Jul 17, 2012, в 12:46, o...@okmij.org написал(а): 1. Haskell's type inference is NON-COMPOSITIONAL! Yes, it is -- and there are many examples of it. Here is an example

Re: [Haskell-cafe] Non-greedy match in Text.Regx.Posix

2012-07-17 Thread Roman Cheplyaka
* C K Kashyap ckkash...@gmail.com [2012-07-17 13:31:05+0530] I was exploring Text.Regex.Posix and found that I was not able to do a non-greedy match by modifying the quantifier with a ?. How can I achieve non-greedy match in Text.Regex.Posix? POSIX regular expressions semantics doesn't have a

Re: [Haskell-cafe] Non-greedy match in Text.Regx.Posix

2012-07-17 Thread C K Kashyap
Thanks Roman, I guess I better invest my time in Parsec then :) Regards, Kashyap On Tue, Jul 17, 2012 at 5:05 PM, Roman Cheplyaka r...@ro-che.info wrote: * C K Kashyap ckkash...@gmail.com [2012-07-17 13:31:05+0530] I was exploring Text.Regex.Posix and found that I was not able to do a

[Haskell-cafe] hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Levent Erkok
[This message is more appropriate for a hackage mailing list I presume, but that doesn't seem to exist. Let me know if there's a better place to send it.] I'm having a hackage compile failure for a newly uplodaded package that has a QuickCheck 2.5 dependence. The error message is: [13 of 13]

[Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Alexander Foremny
Dear Levent, I think this [1] could be related. Regards, Alexander Foremny PS. Sent this to Levent directly. Here's a copy for the mailing list. Sorry for the noise. [1] http://haskell.1045720.n5.nabble.com/Bad-interface-problem-td5714184.html -- Forwarded message -- From:

Re: [Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Levent Erkok
Thanks Alexander. However, I'm not sure how to use the workaround described so I can get hackage to properly compile my package. It sounds like I have to add a template-haskell = 2.7.0.0 dependency to my own cabal file, which sounds like the wrong thing to do in the long-run. Is there something

Re: [Haskell-cafe] Non-greedy match in Text.Regx.Posix

2012-07-17 Thread Brandon Allbery
On Tue, Jul 17, 2012 at 9:54 AM, C K Kashyap ckkash...@gmail.com wrote: I guess I better invest my time in Parsec then :) That's certainly more Haskelly... but it's often possible to rephrase a regexp in POSIX ERE language without using the non-greedy PCREism. What exactly are you trying to

Re: [Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Alexander Foremny
Which package are you trying to build? Is it a local package that fails to build or something on Hackage? Its .cabal file or at least full dependencies would be of interest. Regards, Alexander Foremny 2012/7/17 Levent Erkok erk...@gmail.com: Thanks Alexander. However, I'm not sure how to use

Re: [Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Alexander Foremny
Dear Levent, unfortunately I am at a loss here. As far as I understand it this should be fixed in QuickCheck's .cabal file or on Hackage. But I am not experienced enough to decide. You best wait for someone else to comment on this. Depending on template-haskell in your .cabal file is not the way

Re: [Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Ross Paterson
With ghc 7.4.1, cabal-install 0.13.3 and Cabal 1.14.0, % cabal install --avoid-reinstalls sbv-2.2 fails to find a plan without reinstalls, and recommends --solver=modular. % cabal install --solver=modular --avoid-reinstalls sbv-2.2 reinstalls template-haskell-2.6.0.0, which breaks the GHC

Re: [Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Levent Erkok
Thanks Alexander.. Here's the shocker: I just checked that page again ( http://hackage.haskell.org/package/sbv) and now it's mysteriously fine! Hackage must've recompiled the package somehow. Someone watching this thread must've fixed something on the server and triggered a new compile. While I'm

Re: [Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Levent Erkok
Ah, that explains why the hackage page mysteriously got fixed. Thanks for looking into this Ross. It still feels like this'll start biting more folks down the road. I've created the following cabal ticket so it can be tracked: https://github.com/haskell/cabal/issues/978 However, my

Re: [Haskell-cafe] [Haskell] A riddle...

2012-07-17 Thread Henning Thielemann
On Mon, 16 Jul 2012, Felipe Almeida Lessa wrote: On Mon, Jul 16, 2012 at 12:33 PM, Vo Minh Thu not...@gmail.com wrote: It seems like the infered type (and thus bounds) is different when you force the result to be a Color or not. Just give explicit type signatures and conversion functions.

[Haskell-cafe] Criterion setup/teardown functions?

2012-07-17 Thread tsuraan
Is there anything in Criterion that allows for a benchmark to run some code before or after the thing that it's timing? As an example, I'd like to time a bunch of database inserts, but beforehand I want to create the target table, and afterwards I'd like to delete it. I don't really care to have

Re: [Haskell-cafe] Criterion setup/teardown functions?

2012-07-17 Thread Thomas Schilling
On 17 July 2012 20:45, tsuraan tsur...@gmail.com wrote: Is there anything in Criterion that allows for a benchmark to run some code before or after the thing that it's timing? As an example, I'd like to time a bunch of database inserts, but beforehand I want to create the target table, and

Re: [Haskell-cafe] What is the surefire way to handle all exceptions and make sure the program doesn't fail?

2012-07-17 Thread Bardur Arantsson
On 07/17/2012 08:34 AM, Yifan Yu wrote: First of all, apologise if the question is too broad. The background goes like this: I've implemented a server program in Haskell for my company intended to replace the previous one written in C which crashes a lot (and btw the technology of the company

Re: [Haskell-cafe] What is the surefire way to handle all exceptions and make sure the program doesn't fail?

2012-07-17 Thread Christopher Done
On 17 July 2012 22:10, Bardur Arantsson s...@scientician.net wrote: On 07/17/2012 08:34 AM, Yifan Yu wrote: I can only tell if I browse the source code. So the question is, how can I determine all the exceptions that can be thrown by a given function? Look at its source. Not sure that's the

Re: [Haskell-cafe] What is the surefire way to handle all exceptions and make sure the program doesn't fail?

2012-07-17 Thread Bardur Arantsson
On 07/17/2012 10:17 PM, Christopher Done wrote: On 17 July 2012 22:10, Bardur Arantsson s...@scientician.net wrote: On 07/17/2012 08:34 AM, Yifan Yu wrote: I can only tell if I browse the source code. So the question is, how can I determine all the exceptions that can be thrown by a given

Re: [Haskell-cafe] Criterion setup/teardown functions?

2012-07-17 Thread tsuraan
See the second argument of defaultMainWith http://hackage.haskell.org/packages/archive/criterion/0.6.0.0/doc/html/Criterion-Main.html#v:defaultMainWith. the prep argument is run before the entire suite is run (i.e. once per criterion main invocation); I'm looking for some way to run code before

Re: [Haskell-cafe] What is the surefire way to handle all exceptions and make sure the program doesn't fail?

2012-07-17 Thread Ertugrul Söylemez
Hello there Yifan, exception handling should be done on a per-context basis, where the developer establishes the notion of context. Most of the time this boils down to releasing resources: forkIO (doStuffWith h `finally` hClose h) In more complicated scenarios, where you actually need to

Re: [Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Antoine Latter
Cabal doesn't play well with version constraints on the template-haskell package - it doesn't know it can't reinstall template-haskell. The workaround is to figure out why QuickCheck has version constraints on template-haskell and solve that problem in the QuickCheck package a different way -

Re: [Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Ross Paterson
On Wed, Jul 18, 2012 at 12:14:12AM +0100, Antoine Latter wrote: Cabal doesn't play well with version constraints on the template-haskell package - it doesn't know it can't reinstall template-haskell. The workaround is to figure out why QuickCheck has version constraints on template-haskell

[Haskell-cafe] stripSuffix

2012-07-17 Thread Alvaro Gutierrez
Hi all -- Pardon me if this has been answered before: how come there's a stripPrefix in Data.List, but no matching stripSuffix? Thanks! Alvaro ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] stripSuffix

2012-07-17 Thread Brandon Allbery
On Tue, Jul 17, 2012 at 8:33 PM, Alvaro Gutierrez radi...@google.comwrote: Pardon me if this has been answered before: how come there's a stripPrefix in Data.List, but no matching stripSuffix? Probably because prefixes are easier to do, given the nature of singly linked lists. -- brandon s

Re: [Haskell-cafe] What is the surefire way to handle all exceptions and make sure the program doesn't fail?

2012-07-17 Thread Yifan Yu
On Wed, Jul 18, 2012 at 4:10 AM, Bardur Arantsson s...@scientician.netwrote: The most robust way is probably to use a completely independent supervisor program, e.g. upstart, systemd, runit, etc. These usually have facilities for restarting the supervised program, and a rate limit on exactly

Re: [Haskell-cafe] What is the surefire way to handle all exceptions and make sure the program doesn't fail?

2012-07-17 Thread Yifan Yu
On Wed, Jul 18, 2012 at 7:05 AM, Ertugrul Söylemez e...@ertes.de wrote: exception handling should be done on a per-context basis, where the developer establishes the notion of context. Most of the time this boils down to releasing resources: forkIO (doStuffWith h `finally` hClose h)

Re: [Haskell-cafe] stripSuffix

2012-07-17 Thread Richard O'Keefe
On 18/07/2012, at 12:37 PM, Brandon Allbery wrote: On Tue, Jul 17, 2012 at 8:33 PM, Alvaro Gutierrez radi...@google.com wrote: Pardon me if this has been answered before: how come there's a stripPrefix in Data.List, but no matching stripSuffix? Probably because prefixes are easier to do,

Re: [Haskell-cafe] stripSuffix

2012-07-17 Thread Alvaro Gutierrez
On Tue, Jul 17, 2012 at 11:34 PM, Richard O'Keefe o...@cs.otago.ac.nz wrote: Here are two other possible reasons. It's not just easier, stripPrefix pfx lst is *possible* as long as pfx is finite, even when lst is infinite. The same would not be true of a suffix stripper. Isn't this the case

Re: [Haskell-cafe] Fwd: hackage compile failure with QuickCheck 2.5

2012-07-17 Thread Andres Löh
Hi. QuickCheck's constraint is template-haskell = 2.4, which doesn't explain why cabal wanted to install 2.6.0.0 when 2.7.0.0 was already present. Also, I'd expect --avoid-reinstalls to stop it reinstalling anything, but apparently it doesn't do that with the modular solver. Assuming the