On 2/5/07, Bulat Ziganshin [EMAIL PROTECTED] wrote:
Hello J.,
Sunday, February 4, 2007, 11:46:57 PM, you wrote:
exists s wmap = isJust $ find (==s) . snd = Map.lookup (sort s) wmap
exists s wmap = Map.lookup (sort s) wmap
== snd
== find (==s)
Martin DeMello wrote:
On 2/5/07, Bulat Ziganshin [EMAIL PROTECTED] wrote:
Hello J.,
Sunday, February 4, 2007, 11:46:57 PM, you wrote:
exists s wmap = isJust $ find (==s) . snd = Map.lookup (sort s) wmap
exists s wmap = Map.lookup (sort s) wmap
== snd
==
I have a Data.Map.Map String - (Layout, [String]) as follows:
type Anagrams = [String]
type Cell = (Layout, Anagrams)
type WordMap = Map.Map String Cell
exists str wmap =
let a = Map.lookup (sort str) wmap in
case a of
Nothing - False
Just x - case (find (== str) (snd
On 2/4/07, Martin DeMello [EMAIL PROTECTED] wrote:
I have a Data.Map.Map String - (Layout, [String]) as follows:
type Anagrams = [String]
type Cell = (Layout, Anagrams)
type WordMap = Map.Map String Cell
exists str wmap =
let a = Map.lookup (sort str) wmap in
case a of
Maybe has a Monad instance, so you can write this as follows (untested):
exists str wmap = boolFromMaybe exists'
where exists' =
do x - Map.lookup (sort str) wmap
find (== str) (snd x)
boolFromMaybe (Just _) = True
boolFromMaybe Nothing = False
On Sun, 2007-02-04 at 19:54 +0530, Martin DeMello wrote:
I have a Data.Map.Map String - (Layout, [String]) as follows:
type Anagrams = [String]
type Cell = (Layout, Anagrams)
type WordMap = Map.Map String Cell
exists str wmap =
let a = Map.lookup (sort str) wmap in
case a of
On 2/4/07, Udo Stenzel [EMAIL PROTECTED] wrote:
J. Garrett Morris wrote:
Small improvement (Data.Maybe is underappreciated):
exists str wmap = isJust exists'
where exists' =
do x - Map.lookup (sort str) wmap
find (== str) (snd x)
This is true. Some time
Hi
This is true. Some time ago I swore off the use of fromRight and
fromLeft in favor of maybe, and have been forgetting about the other
functions in Data.Maybe ever since.
I think you mean you swore off fromJust. Unfortunately when people
started to debate adding fromLeft and fromRight they
J. Garrett Morris wrote:
On 2/4/07, Udo Stenzel [EMAIL PROTECTED] wrote:
exists s wmap = isJust $ Map.lookup (sort s) wmap = find (== s) . snd
If you're going to write it all on one line, I prefer to keep things
going the same direction:
Hey, doing it this way saved me a full two
u.stenzel:
J. Garrett Morris wrote:
On 2/4/07, Udo Stenzel [EMAIL PROTECTED] wrote:
exists s wmap = isJust $ Map.lookup (sort s) wmap = find (== s) . snd
If you're going to write it all on one line, I prefer to keep things
going the same direction:
Hey, doing it this way saved me a
On 2/4/07, Udo Stenzel [EMAIL PROTECTED] wrote:
J. Garrett Morris wrote:
On 2/4/07, Udo Stenzel [EMAIL PROTECTED] wrote:
Well, depends on whether we are allowed to define new combinators. I
sometimes use
-- Kleisli composition
infixl 1 @@
(@@) :: Monad m = (a - m b) - (b - m c) - (a - m c)
f
11 matches
Mail list logo