On 11/01/2012, at 19:28, Dan Doel wrote: > Then I'm afraid I still don't understand the difference. Is it that > case in core always evaluates? So: > > case undefined of x -> ... > > blows up, while > > case (# undefined #) of (# x #) -> ... > > does not?
Yes. > Also, if so, how is (core-wise): > > foo :: ... -> (# T #) > case foo <v> of (# x #) -> ... > > different from: > > foo :: ... -> T > let x = foo <v> in ... > > Stack vs. heap allocation? The second version binds x to a thunk that, when evaluated, calls foo <v> (which yields an evaluated T). The first one calls foo <v> and then binds x to whatever T (possibly unevaluated) it returns. It really is exactly the same as: data Box a = Box a foo :: ... -> Box T case foo <v> of Box x -> ... vs. foo :: ... -> T let x = foo <v> in ... Except that Box T is lifted and (# T #) isn't. Roman _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users