
I also worked under the relaxed interpretation, and it is surprising to me that GHC does better. if GHC will do even better, I'd try to first formulate what that better is. "a local binding group is closed if all variables free in the group are bound at top-level" is somewhat understandable, adding further exceptions makes more programs to type-check, but if specifications becomes more cumbersome verifying that implementations does what specification advertises becomes more difficult. The "the variable has an explicit type signature that has no free type variables" additions seems arbitrary, it's not motivated in the manual. How much of the "real code" will break if it is removed? - Oleg On 11.2.2021 17.03, Richard Eisenberg wrote:
On Feb 11, 2021, at 9:23 AM, Tom Ellis
mailto:tom-lists-haskell-cafe-2017@jaguarpaw.co.uk> wrote: "In pFG, the argument pBArg has been given a type (moreover a monomorphic type) by the type signature for pFG itself. Why does the definition of 'closed' require the variable to be let-bound? Wouldn't lambda-bound with a type implicitly provided by an explicit type signature for the lambda" be equally good?"
I think so, yes.
Full disclosure: before this thread, I had never looked closely at the MonoLocalBinds definition. For years, I was operating under a simpler premise: "a local binding group is closed if all variables free in the group are bound at top-level". That is, any binding group that capture variables from the local definition would not be generalized. This interpretation means that your definition within pFG1 would also not be generalized. But my working definition was too limited, as the manual explains.
Bottom line: I think you're right that we could do more generalization. I'm not sure how easy this would be to implement (I don't know how GHC tracks this information off the top of my head), but I do think it's worth filing a ticket to see if we can easily do better.
Good conversation! I've learned something here.
Thanks, Richard
_______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.