<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hi,</p>
<p>Yes it's correct. You can check this with ghci:</p>
<p>f :: Integer -> Maybe Integer<br>
f 5 = Nothing<br>
f x = Just x<br>
<br>
> let xs = [1..] :: [Integer]<br>
> mapM f xs<br>
Nothing (it doesn't loop forever)<br>
> :sprint xs<br>
xs = 1 : 2 : 3 : 4 : 5 : _ (the tail after 5 is not evaluated)<br>
</p>
Cheers<br>
Sylvain<br>
<br>
<div class="moz-cite-prefix">On 22/09/2016 11:57, Dennis Raddle
wrote:<br>
</div>
<blockquote
cite="mid:CAKxLvoo4AuA=3Y9FVBW6qMmJm3N8KshE7krX=n6wWpQ+++PBug@mail.gmail.com"
type="cite">
<div dir="ltr">I want to evaluate a function on a series of
inputs:
<div><br>
</div>
<div>f :: a -> Maybe b</div>
<div><br>
</div>
<div>then collect the results [b] if they are all Just, or
terminate the computation immediately upon hitting Nothing. </div>
<div><br>
</div>
<div>This is exactly what mapM does in the Maybe monad, correct?</div>
<div><br>
</div>
<div>In particular I want to make sure that it will not try to
evaluate anything past the first 'Nothing' result as the
efficiency of my design is based on that.</div>
<div><br>
</div>
<div>D</div>
<div><br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Beginners mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Beginners@haskell.org">Beginners@haskell.org</a>
<a class="moz-txt-link-freetext" href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a>
</pre>
</blockquote>
<br>
</body>
</html>