When is my Haskell expression evaluated?
问题 If I define λ> data Bar = Bar Int deriving Show λ> data Foo = Foo Bar deriving Show and λ> let foo = trace "foo" Foo (trace "bar" Bar 100) λ> let two = trace "two" 2 λ> let g (Foo x) y = y then I think I understand why I get λ> g foo two foo two 2 But if I then repeat this, I get λ> g foo two two 2 and I don't understand why foo appears not to have been evaluated for the second invocation of g , especially since it is clearly not (yet) somehow already available, as I can verify with λ> foo