[Haskell-cafe] Disjunctive patterns

2011-12-08 Thread Asger Feldthaus
Haskell doesn't seem to support disjunctive patterns, and I'm having a difficult time writing good Haskell code in situations that would otherwise call for that type of pattern. Suppose for an example I have this data type: data T = Foo Int | Bar Int | Baz In OCaml I can write something like:

Re: [Haskell-cafe] Why doesn't this work? (palindrome :: IO)

2011-12-08 Thread Paul R
Alexej The interesting thing is, that if I change the case ... of Alexej statement to an if ... then ... else statement, this magically Alexej starts to work. Since I no longer am enrolled (I have to take Alexej the course next year), I can't ask a teacher, but my curiosity Alexej still bugs me.

Re: [Haskell-cafe] Disjunctive patterns

2011-12-08 Thread Serguey Zefirov
2011/12/8 Asger Feldthaus asger.feldth...@gmail.com: Haskell doesn't seem to support disjunctive patterns, and I'm having a difficult time writing good Haskell code in situations that would otherwise call for that type of pattern. Suppose for an example I have this data type: data T = Foo

Re: [Haskell-cafe] Disjunctive patterns

2011-12-08 Thread Emil Axelsson
Instead of pattern guards you can use ViewPatterns: http://hackage.haskell.org/trac/ghc/wiki/ViewPatterns This reduces some of the noise. {-# LANGUAGE ViewPatterns #-} data T = Foo Int | Bar Int | Baz fooBar (Foo a) = Just a fooBar (Bar a) = Just a fooBar _

Re: [Haskell-cafe] Disjunctive patterns

2011-12-08 Thread Øystein Kolsrud
Or perhaps this? data T = Foo Int | Bar Int | Baz fooBar (Foo a) = Just a fooBar (Bar a) = Just a fooBar _ = Nothing foo :: T - T - Int foo x y = sum $ catMaybes $ map fooBar [x,y] /Øystein On Thu, Dec 8, 2011 at 1:15 PM, Emil Axelsson e...@chalmers.se wrote: Instead of pattern guards

[Haskell-cafe] Converting string to System.Time.ClockTime

2011-12-08 Thread dokondr
Hi, What would be the simplest way to convert strings like Wed, 07 Dec 2011 10:09:21 + to System.Time.ClockTime ? Thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Disjunctive patterns

2011-12-08 Thread David Waern
2011/12/8 Asger Feldthaus asger.feldth...@gmail.com: Haskell doesn't seem to support disjunctive patterns, and I'm having a difficult time writing good Haskell code in situations that would otherwise call for that type of pattern. I've also missed this after having done a bit of OCaml coding.

Re: [Haskell-cafe] Disjunctive patterns

2011-12-08 Thread Holger Siegel
Am 08.12.2011 um 11:13 schrieb Asger Feldthaus: Haskell doesn't seem to support disjunctive patterns, and I'm having a difficult time writing good Haskell code in situations that would otherwise call for that type of pattern. In Haskell I can't find any equivalent to the disjunctive

Re: [Haskell-cafe] Converting string to System.Time.ClockTime

2011-12-08 Thread Erik Hesselink
I'm not sure if you really need ClockTime (from old-time), but if you don't, the types from the 'time' package are all parseable with `parseTime` [1]. Erik [1] http://hackage.haskell.org/packages/archive/time/latest/doc/html/Data-Time-Format.html#v:parseTime On Thu, Dec 8, 2011 at 14:16,

Re: [Haskell-cafe] Converting string to System.Time.ClockTime

2011-12-08 Thread dokondr
I need to parse time strings like Wed, 07 Dec 2011 10:09:21 + to a type that: 1) implements Eq, Ord 2) is numerical, so I could subtract one value from another to find the difference or interval length To answer 1) requirement I wrote the following snippet. Yet I could not subtract UTCTime

Re: [Haskell-cafe] Converting string to System.Time.ClockTime

2011-12-08 Thread dokondr
Now, when I have managed to convert UTCTime to seconds (see code below) I got stuck trying to convert from UTCTime to CalendarTime, how to do this? import Data.Time.Format import Data.Time.Clock import Locale import Data.Maybe import Data.Time.Clock.POSIX s1 = Wed, 07 Dec 2011 10:09:21 + s2

Re: [Haskell-cafe] Converting string to System.Time.ClockTime

2011-12-08 Thread Antoine Latter
On Thu, Dec 8, 2011 at 9:01 AM, dokondr doko...@gmail.com wrote: Now, when I have managed to convert UTCTime to seconds (see code below) I got stuck trying to convert from UTCTime to CalendarTime, how to do this? It might be easier to use 'diffUTCTime' and 'addUTCTime' instead of converting

Re: [Haskell-cafe] Converting string to System.Time.ClockTime

2011-12-08 Thread Antoine Latter
On Thu, Dec 8, 2011 at 9:13 AM, Antoine Latter aslat...@gmail.com wrote: On Thu, Dec 8, 2011 at 9:01 AM, dokondr doko...@gmail.com wrote: Now, when I have managed to convert UTCTime to seconds (see code below) I got stuck trying to convert from UTCTime to CalendarTime, how to do this? It

Re: [Haskell-cafe] Converting string to System.Time.ClockTime

2011-12-08 Thread dokondr
Ok, maybe you could advise what packages to use for this simple scenario: I have two text strings with dates: s1 = Wed, 07 Dec 2011 10:09:21 + s2 = Wed, 07 Dec 2011 10:11:00 + I need: 1) Find how many seconds are between these dates 2) Calculate the date in the middle between these

Re: [Haskell-cafe] Converting string to System.Time.ClockTime

2011-12-08 Thread Antoine Latter
On Thu, Dec 8, 2011 at 9:30 AM, dokondr doko...@gmail.com wrote: Ok, maybe you could advise what packages to use for this simple scenario: I have two text strings with dates: s1 = Wed, 07 Dec 2011 10:09:21 + s2 = Wed, 07 Dec 2011 10:11:00 + I need: 1) Find how many seconds are

Re: [Haskell-cafe] Converting string to System.Time.ClockTime

2011-12-08 Thread dokondr
On Thu, Dec 8, 2011 at 7:39 PM, Antoine Latter aslat...@gmail.com wrote: On Thu, Dec 8, 2011 at 9:30 AM, dokondr doko...@gmail.com wrote: Ok, maybe you could advise what packages to use for this simple scenario: I have two text strings with dates: s1 = Wed, 07 Dec 2011 10:09:21 +

[Haskell-cafe] Recommended class instances for container type

2011-12-08 Thread Christoph Breitkopf
Hello, I'm in the process of implementing a container data type, and wonder what class instances are generally considered necessary. E.g. is it ok to start out with a Show that's adequate for debugging, or is it a 'must' to include instances of everything possible (Eq, Ord if possible, Read,

Re: [Haskell-cafe] Recommended class instances for container type

2011-12-08 Thread Edward Z. Yang
I'd hazard that if you went 'containers' and looked at what instances were implemented, that would give you a good idea. :^) (For example, if you look at Data.MAp, it has NFData, Typeable2 and Data instances.) Edward Excerpts from Christoph Breitkopf's message of Thu Dec 08 11:12:06 -0500 2011:

Re: [Haskell-cafe] Recommended class instances for container type

2011-12-08 Thread Christoph Breitkopf
That's what I did, and the reason for my question. 'Cause I was scared off by looking at Data.Map (CPP, lots of language extensions). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Recommended class instances for container type

2011-12-08 Thread Bryan O'Sullivan
On Thu, Dec 8, 2011 at 8:12 AM, Christoph Breitkopf chbreitk...@googlemail.com wrote: I'm in the process of implementing a container data type, and wonder what class instances are generally considered necessary. E.g. is it ok to start out with a Show that's adequate for debugging, or is it a

Re: [Haskell-cafe] Recommended class instances for container type

2011-12-08 Thread Christoph Breitkopf
Hello Bryan, On Thu, Dec 8, 2011 at 6:03 PM, Bryan O'Sullivan b...@serpentine.com wrote: And what about the more experimental things? Say, DeepSeq, Typeable, Data? None of those are experimental. They're all frequently used in production code. DeepSeq is far more important than the other

Re: [Haskell-cafe] Recommended class instances for container type

2011-12-08 Thread Daniel Fischer
On Thursday 08 December 2011, 18:13:50, Christoph Breitkopf wrote: Well, including a some file via CPP did look experimental enough to me. I'd like to stay away from GHC-only code, if possible. CPP is standard (maybe not in the sense that it's included in the language standard, but every

Re: [Haskell-cafe] More liberal than liberal type synonyms

2011-12-08 Thread Brent Yorgey
On Wed, Dec 07, 2011 at 04:47:47PM +0100, Gábor Lehel wrote: On Wed, Dec 7, 2011 at 1:07 PM, Dmitry Kulagin dmitry.kula...@gmail.com wrote: For short, type synonyms work for mere aliases, but not for full-fledged type-level non-inductive functions. And sometimes we intuitively want to

Re: [Haskell-cafe] Recommended class instances for container type

2011-12-08 Thread Johan Tibell
On Thu, Dec 8, 2011 at 8:12 AM, Christoph Breitkopf chbreitk...@googlemail.com wrote: Hello, I'm in the process of implementing a container data type, and wonder what class instances are generally considered necessary. E.g. is it ok to start out with a Show that's adequate for debugging, or

Re: [Haskell-cafe] Why doesn't this work? (palindrome :: IO)

2011-12-08 Thread Tom Murphy
On Wed, Dec 7, 2011 at 11:46 PM, Brandon Allbery allber...@gmail.comwrote: On Wed, Dec 7, 2011 at 23:24, Alexej Segeda aloscha_den_st...@hotmail.com wrote: case s of (s == reverse s)- putStrLn (s ++ is a palindrome) otherwise

[Haskell-cafe] Does anyone maintain trac.haskell.org?

2011-12-08 Thread Justin Bailey
The community Trac hosting server isn't sending email, which Trac requires. I've submitted several tickets to supp...@community.haskell.org but gotten no response. Does anyone maintain that server anymore? Justin ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Does anyone maintain trac.haskell.org?

2011-12-08 Thread Alistair Bayley
On 9 December 2011 10:39, Justin Bailey jgbai...@gmail.com wrote: The community Trac hosting server isn't sending email, which Trac requires. I've submitted several tickets to supp...@community.haskell.org but gotten no response. Does anyone maintain that server anymore? Had the same

Re: [Haskell-cafe] Why doesn't this work? (palindrome :: IO)

2011-12-08 Thread Brandon Allbery
On Thu, Dec 8, 2011 at 15:52, Tom Murphy amin...@gmail.com wrote: On Wed, Dec 7, 2011 at 11:46 PM, Brandon Allbery allber...@gmail.comwrote: case () of () | s == reverse s - putStrLn palindrome _ - putStrLn nope This is kind of a hack of case, though. I think

[Haskell-cafe] [ANNOUNCE] cereal-0.3.5.0

2011-12-08 Thread Trevor Elliott
Hi Everyone, I'm pleased to announce the release of cereal version 0.3.5.0! New to this release is support for default, generic implementations of the get and put methods of the Serialize class, when support is available. This functionality comes to you courtesy of Bas van Dijk. Happy

[Haskell-cafe] CfP: Only one week left for submitting abstracts to TAP 2012 (International Conference on Test and Proofs

2011-12-08 Thread Achim D. Brucker
(Apologies for duplicates) * Less than one week until the deadline *** for submitting abstract to TAP 2012*** *