On Mon, May 23, 2011 at 6:21 PM, Richard O'Keefe o...@cs.otago.ac.nz wrote:
On 24/05/2011, at 5:49 AM, Alexander Solla wrote:
There's a library function for it, but also:
filter ((/=) Nothing)
The problem with that in general is that it only
applies to [Maybe t] if Eq t, but you don't
Alexander Solla schrieb:
Personally, I find non-functional values without Eq instances to be
degenerate. So I really do not mind superfluous Eq constraints. I
would not hesitate to use filter ((/=) Nothing) in a function whose type
has no free type variables. It's just a bit of plumbing
Personally, I find non-functional values without Eq instances to be
degenerate. So I really do not mind superfluous Eq constraints. I
would not hesitate to use filter ((/=) Nothing) in a function whose type
has no free type variables. It's just a bit of plumbing inside of a
more
What's the best way to end up with a list composed of only the Just values,no
Nothings?
Michael
==
import Control.Monad.Stateimport Data.Maybe
type GeneratorState = State Int
tick :: GeneratorState (Maybe Int)tick = do n - get if ((n `mod` 7)
== 0)
On 23 May 2011, at 17:20, michael rice wrote:
What's the best way to end up with a list composed of only the Just values,
no Nothings?
Go to haskell.org/hoogle
Type in [Maybe a] - [a]
Click on first result.
___
Haskell-Cafe mailing list
On 5/23/11 9:20 AM, michael rice wrote:
What's the best way to end up with a list composed of only the Just
values,
no Nothings?
Try catMaybes in Data.Maybe.
Cheers,
Greg
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
On 23 May 2011 17:20, michael rice nowg...@yahoo.com wrote:
What's the best way to end up with a list composed of only the Just values,
no Nothings?
http://haskell.org/hoogle/?hoogle=%3A%3A+%5BMaybe+a%5D+-%3E+%5Ba%5D
Data.Maybe.catMaybes is what you want :-)
Cheers,
Max
On 23 May 2011, at 17:20, michael rice wrote:
What's the best way to end up with a list composed of only the Just values,
no Nothings?
Alternatively,
[ x | Just x - originals ]
It also occurs to me that perhaps you still want the Just constructors.
[ Just x | Just x -
On 5/23/11 9:29 AM, Max Bolingbroke wrote:
On 23 May 2011 17:20, michael rice nowg...@yahoo.com
mailto:nowg...@yahoo.com wrote:
What's the best way to end up with a list composed of only the
Just values,
no Nothings?
On Mon, May 23, 2011 at 9:20 AM, michael rice nowg...@yahoo.com wrote:
What's the best way to end up with a list composed of only the Just values,
no Nothings?
Michael
==
import Control.Monad.State
import Data.Maybe
type GeneratorState = State Int
tick ::
leads to another. It's interesting how ideas begin bubbling up
after one absorbs some critical mass of Haskell.
Michael
--- On Mon, 5/23/11, Malcolm Wallace malcolm.wall...@me.com wrote:
From: Malcolm Wallace malcolm.wall...@me.com
Subject: Re: [Haskell-cafe] [Maybe Int] sans Nothings
On Mon, May 23, 2011 at 10:49:55AM -0700, Alexander Solla wrote:
On Mon, May 23, 2011 at 9:20 AM, michael rice nowg...@yahoo.com wrote:
What's the best way to end up with a list composed of only the Just values,
no Nothings?
Michael
==
import
On 05/23/2011 12:08 PM, Brent Yorgey wrote:
Just a minor quibble: note that
filter (not . isNothing)
is slightly preferable since it does not introduce a frivolous
equality constraint on the type wrapped by the Maybe.
Or even better,
filter isJust
:-)
Cheers,
Greg
Brent Yorgey schrieb:
On Mon, May 23, 2011 at 10:49:55AM -0700, Alexander Solla wrote:
There's a library function for it, but also:
filter ((/=) Nothing)
is readable enough.
Just a minor quibble: note that
filter (not . isNothing)
is slightly preferable since it does not introduce a
Gregory Crosswhite gcr...@phys.washington.edu wrote:
Or even better,
filter isJust
To make it worse again the original function can be generalized in a few
ways. Here is a generalization from the inner Maybe type:
import Data.Foldable as F
catFoldables :: Foldable t = [t a] -
On 24/05/2011, at 5:49 AM, Alexander Solla wrote:
There's a library function for it, but also:
filter ((/=) Nothing)
The problem with that in general is that it only
applies to [Maybe t] if Eq t, but you don't
actually _need_ t to support equality.
filter isJust
will do the job, where
16 matches
Mail list logo