[Haskell-beginners] Evaluate function
Daniel Fischer
daniel.is.fischer at googlemail.com
Mon May 26 10:21:54 UTC 2014
On Monday 26 May 2014, 10:00:33, Derek McLoughlin wrote:
> Reading "Parallel and Concurrent Programming in Haskell", at the bottom of
> page 27 the author wants to force the evaluation of a list of Strings:
>
> evaluate ( length puzzles )
>
> Why not just
>
> evaluate puzzles
>
> ?
>
> https://github.com/simonmar/parconc-examples/blob/master/sudoku4.hs
Because "evaluate" means "evaluate to weak head normal form", that is, to the
outermost constructor or lambda.
evaluate puzzles
would evaluate the list just so far that it is known whether the list is empty
or not.
To evaluate something completely, one needs to evaluate a value that depends
on the complete structure. Presumably, to determine the length of the list,
one needs to evaluate all paths completely to see whether they lead to a valid
puzzle, hence the evaluation is forced by demanding the evaluation of the
length.
More information about the Beginners
mailing list