<p dir="ltr">You can't return Nothing, because your function doesn't return a maybe. If you make it a maybe, you just need to return the value of g without further processing. </p>
<div class="gmail_quote">Am 21.04.2014 19:53 schrieb "KC" <<a href="mailto:kc1956@gmail.com">kc1956@gmail.com</a>>:<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>