[Haskell-cafe] beginners question about fromMaybe
shinnonoir at gmail.com
Tue Jun 2 19:24:46 EDT 2009
I just noticed that my suggestion doesn't work. You're testing whether
val is Nothing and in my code snipped val has a different type.
On 6/3/09, Raynor Vliegendhart <shinnonoir at gmail.com> wrote:
> If you're absolutely certain that the lookup always succeeds, then you
> can use pattern matching as follows:
> jr = joinTuples sc x val
> key = getPartialTuple is x
> Just val = Map.lookup key m
> On 6/3/09, Nico Rolle <nrolle at web.de> wrote:
> > hi there
> > heres a code snipped, don't care about the parameters.
> > the thing is i make a lookup on my map "m" and then branch on that return value
> > probePhase is sc  m = 
> > probePhase is sc (x:xs) m
> > | val == Nothing = probePhase is sc xs m
> > | otherwise = jr ++ probePhase is sc xs m
> > where
> > jr = joinTuples sc x (fromMaybe  val)
> > key = getPartialTuple is x
> > val = Map.lookup key m
> > the line "jr = joinTuples sc x (fromMaybe  val)" is kind of ugly
> > because i know that it is not Nothing.
> > is there a better way to solve this?
> > regards
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
More information about the Haskell-Cafe