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:
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.
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
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 _
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
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
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.
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
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,
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
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
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
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
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
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
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 +
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,
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:
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
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
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
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
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
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
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
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
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
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
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
(Apologies for duplicates)
*
Less than one week until the deadline ***
for submitting abstract to TAP 2012***
*
30 matches
Mail list logo