If I pattern-match against an expression whose type has only one constructor, will that still force the runtime to evaluate the expression to WHNF?
I did an experiment that seems to indicate it doesn't evaluate:
Prelude> data Test = Test Int Int
Prelude> let errorpr () = error "Fail"
Prelude> let makeTest f = let (x,y) = f () in Test x y
Prelude> let x = makeTest errorpr
Prelude> let Test z1 z2 = x
Prelude> :sprint z1
z1 = _
Prelude> :sprint z2
z2 = _
Prelude> :sprint x
x = _
I would have expected to either get an error or :sprint x to yield
x = Test _ _
but it didn't.
Apparently I didn't understand how "let" works. See the answers below