The function mkWeak is useful for building various low-level abstractions in Haskell. (See here for documentation.) It was not clear to me what the behavior was when it is passed a (key, value) pair where the value is an unevaluated thunk. Will it evaluate the thunk before making the weak pointer, or is it held unevaluated. I’m sure that there’s some clever expression I can type involving undefined to resolve this one way or the other, but I can’t think what it is!
The function mkWeak is useful for building various low-level abstractions in Haskell. (See here
Share
Remember, a strict function has to return bottom if given bottom as an argument, so you can test the strictness of a function by giving it
undefinedas an argument and observing whether you get an exception or not.A quick experiment indicates that
mkWeakis not strict in its second argument. (And I don’t see a good reason why it would be, anyway).