tsuraan tsur...@gmail.com wrote:
Is there a more concise way to do this?
I use
someIO = f where
f Opt1 = ...
If it's a common pattern, you can even do
opts f _ _ (Opt1 x) = f x
opts _ g _ (Opt2 x) = g x
opts _ _ h (Opt3 x) = h x
. Functions are easier to mess around with than case
On Mon, 2011-03-14 at 17:56 +0100, Yves Parès wrote:
If you have only one alternative, then you can simply do:
Opt1 - someIO
E.g., if you are _sure_ that foo returns always a 'Just' within a monad you
can perfectly do :
Just x - foo
Please beware - it is not exactly the same as with
Quoth Achim Schneider bars...@web.de,
...
I use
someIO = f where
f Opt1 = ...
If it's a common pattern, you can even do
opts f _ _ (Opt1 x) = f x
opts _ g _ (Opt2 x) = g x
opts _ _ h (Opt3 x) = h x
. Functions are easier to mess around with than case expressions.
I like
Hello tsuraan,
Most often, when we multi-pattern-match on the return value of a monadic
computation, we talk about Maybe or Either or [], and I often find
myself doing this:
someIO1 :: IO (Maybe A)
someIO2 :: IO (Either A B)
result1 - someIO1 = maybe ...
result2 - someIO2 =
Hi,
Donn Cave wrote:
someIO= f where
f Opt1 = ...
I like this ... or, I would like it, if I could make it work!
I get The last statement in a 'do' construct must be an expression,
Where-clauses can only be used on equations, not on expressions or
statements, so you would need
Quoth Tillmann Rendel ren...@informatik.uni-marburg.de,
...
Where-clauses can only be used on equations, not on expressions or
statements, so you would need to float the where clause outwards:
So ... not to put too fine a point on it, but ... as useful as
function notation could be for the
In my code, I'm doing this quite a lot:
x - someIO
case x of
Opt1 - ...
Having a line for extracting the value from the IO (or STM) and then
acting on the value seems unnatural. Is there a more concise way to
do this? This code:
case someIO of
Opt1 - ...
Doesn't work, but is there
See this thread:
http://www.haskell.org/pipermail/haskell-cafe/2010-October/084291.html
On 14 March 2011 15:48, tsuraan tsur...@gmail.com wrote:
In my code, I'm doing this quite a lot:
x - someIO
case x of
Opt1 - ...
Having a line for extracting the value from the IO (or STM) and then
-boun...@haskell.org
[mailto:haskell-cafe-boun...@haskell.org] On Behalf Of tsuraan
Sent: 14 March 2011 15:49
To: haskell-cafe@haskell.org
Subject: [Haskell-cafe] Question on a common pattern
In my code, I'm doing this quite a lot:
x - someIO
case x of
Opt1 - ...
Having a line for extracting
If you have only one alternative, then you can simply do:
Opt1 - someIO
E.g., if you are _sure_ that foo returns always a 'Just' within a monad you
can perfectly do :
Just x - foo
2011/3/14 tsuraan tsur...@gmail.com
In my code, I'm doing this quite a lot:
x - someIO
case x of
Opt1 -
See this
thread: http://www.haskell.org/pipermail/haskell-cafe/2010-October/084291.html
Which links to http://hackage.haskell.org/trac/ghc/ticket/4359 .
Looks like there's already been quite a bit of discussion on this
already :) Thanks for the link.
If you have only one alternative, then you can simply do:
Opt1 - someIO
E.g., if you are _sure_ that foo returns always a 'Just' within a monad you
can perfectly do :
Just x - foo
That's interesting. I had no idea that one could do that. I think
what I'm looking for is something along
12 matches
Mail list logo