[Haskell] specified or not
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Thu Mar 3 09:45:14 EST 2005
Scott Turner <p.turner at computer.org> writes:
> Is the behavior of evaluating z unspecified?
> z = f (0, z)
> f x = case x of
> (1,1) -> z
> _ -> 0
> Hugs and GHC agree that z evaluates to 0. However, if the first line is
> changed to
> z = f (z,0)
> then both implementations loop. In other words, the behavior depends on
> order of evaluation, which AFAIK is not specified.
Patterns are matched left-to-right, which fully explains the behaviour
you see.
Haskell Report section 3.17.2, Informal Semantics of Pattern Matching
Regards,
Malcolm
More information about the Haskell
mailing list