[Haskell-cafe] Re: Why is this strict in its arguments?

Paulo J. Matos pocm at soton.ac.uk
Wed Dec 5 11:40:06 EST 2007


On Dec 5, 2007 1:43 PM, Benja Fallenstein <benja.fallenstein at gmail.com> wrote:
> Hi Paolo,
>
> On Dec 5, 2007 2:09 PM, Paulo J. Matos <pocm at soton.ac.uk> wrote:
> > I'm glad that my initial post generated such an interesting discussion
> > but I'm still not understanding why the first version of findAllPath
> > seems to be computing the whole list even when I just request the
> > head, while the second one doesn't.
>
> Because the function starts its work with
>
>     if isNothing lfpaths && isNothing rtpaths
>     then Nothing
>     else ...
>
> which forces the evaluation of 'lfpaths' and 'rtpaths' to see whether
> they are Just or Nothing, which recursively forces the evaluation of
> findAllPath for the whole tree.
>

Oh, but lfpaths is not nothing so that means that isNothing rtpaths
shouldn't be evaluated, right?

> Hope this helps,
> - Benja
>
>
>



-- 
Paulo Jorge Matos - pocm at soton.ac.uk
http://www.personal.soton.ac.uk/pocm
PhD Student @ ECS
University of Southampton, UK


More information about the Haskell-Cafe mailing list