<p dir="ltr">If the result of weight is (Maybe t) instead of the then the result of the array lookup can be passed out directly for the caller to check:</p>
<p dir="ltr">weight x y g = g!(x, y) </p>
<p dir="ltr">Is this what you mean? </p>
<p dir="ltr">Cheers, <br>
Darren </p>
<div class="gmail_quote">On Apr 21, 2014 10:53 AM, "KC" <<a href="mailto:kc1956@gmail.com">kc1956@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><div>How do I return Nothing from a function?<br><br>When there is no edge in the graph this code fails.<br>*** Exception: Graph.hs:65:9-26: Irrefutable pattern failed for pattern (Data.Maybe.Just w)<br><br>

<br clear="all">*Main> :t weight<br>weight<br>  :: (Ix t1, Ix t2) => t1 -> t2 -> Array (t1, t2) (Maybe t) -> t<br><br>weight x y g = w<br>    where<br>        (Just w) = g!(x,y)<br><br><br></div>Thank you for your time.<br>

<br><div>-- <br><div dir="ltr"><p dir="ltr">--<br>
</p><p dir="ltr">Sent from an expensive device which will be obsolete in a few months! :D</p>
Casey<br><br></div>
</div></div>
<br>_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">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>
<br></blockquote></div>