Hello Martin,<br><br>You have two options. You can use fromJust :: Maybe a -&gt; a, which is a partial function, so it can fail if the supplied value is Nothing and gives a hard to track down exception. <br><br>Or you can use fromMaybe :: a -&gt; Maybe a -&gt; a,  which returns a default a in case Maybe a = Nothing and a if Maybe a = Just a. <br>

<br>There is also a third: maybe :: b -&gt; (a -&gt; b) -&gt; Maybe a -&gt; b, which can be useful in the last step of some chain of functions. Note that fromMaybe is just (flip maybe id).<br><br>Greets,<br><br>Edgar <br>

<br><div class="gmail_quote">On Tue, Sep 21, 2010 at 3:05 PM, Martin Tomko <span dir="ltr">&lt;<a href="mailto:martin.tomko@geo.uzh.ch">martin.tomko@geo.uzh.ch</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

Dear All,<br>
as a newbie, I am only just discovering some intricacies of haskell.<br>
I have a Data.Map map, and am trying the lookup function to get the value for a given key (it is a list in my case, btw). I am struggling to get access to the value, as it is constructed using Just. I know that the question is therefore more general then the application on Map, so I would be glad to get a wider picture. I Checked in Real World Haskell, btu did nto find and answer. In Haskell the craft of... I found the following (p263):<br>


<br>
mapValue :: (a-&gt;b)-&gt; Maybe a -&gt; Maybe b<br>
mapValue g (Just a) = Just (g a)<br>
mapValue g Nothing = Nothing<br>
<br>
Which is fine, but it makes the Just constructor travel through the whole code, which is annoying. Is there a way out? Or would that be a dirty hack?<br>
<br>
I do not quite understand the following discussion of maybe (p263-4), but it seems like the code suggested is able to return a value at the end...<br>
<br>
Thanks<br>
Martin<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
</blockquote></div><br>