You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In GHC 9.0 and below, the following code would produce an error message that mentions the phrase type variable 's' would escape its scope.
runST (newSTRef 5)
<interactive>:3:8: error:
• Couldn't match type ‘a’ with ‘STRef s Integer’
Expected: ST s a
Actual: ST s (STRef s Integer)
because type variable ‘s’ would escape its scope
This (rigid, skolem) type variable is bound by
a type expected by the context:
forall s. ST s a
at <interactive>:3:7-18
• In the first argument of ‘runST’, namely ‘(newSTRef 5)’
In the expression: runST (newSTRef 5)
In an equation for ‘it’: it = runST (newSTRef 5)
• Relevant bindings include it :: a (bound at <interactive>:3:1)
GHC >= 9.2 only reports the type mismatch and doesn't mention anything about escaping scopes anymore.
<interactive>:3:8: error: [GHC-25897]
• Couldn't match type ‘a’ with ‘STRef s Integer’
Expected: ST s a
Actual: ST s (STRef s Integer)
‘a’ is a rigid type variable bound by
the inferred type of it :: a
at <interactive>:3:1-18
• In the first argument of ‘runST’, namely ‘(newSTRef 5)’
In the expression: runST (newSTRef 5)
In an equation for ‘it’: it = runST (newSTRef 5)
• Relevant bindings include it :: a (bound at <interactive>:3:1)
That s would escape its scope is arguably the most important part of the error message, so if this is reverted, that line should probably be moved before the type mismatch. Especially in cases like this with runST, the type mismatch is not very meaningful without that piece of information.
For example:
<interactive>:3:8: error: [GHC-25897]
• The rigid type variable 's' would escape its scope
• Couldn't match type ‘a’ with ‘STRef s Integer’
Expected: ST s a
Actual: ST s (STRef s Integer)
‘a’ is a rigid type variable bound by
the inferred type of it :: a
at <interactive>:3:1-18
• In the first argument of ‘runST’, namely ‘(newSTRef 5)’
In the expression: runST (newSTRef 5)
In an equation for ‘it’: it = runST (newSTRef 5)
• Relevant bindings include it :: a (bound at <interactive>:3:1)
The text was updated successfully, but these errors were encountered:
In GHC 9.0 and below, the following code would produce an error message that mentions the phrase
type variable 's' would escape its scope
.runST (newSTRef 5)
GHC >= 9.2 only reports the type mismatch and doesn't mention anything about escaping scopes anymore.
That
s
would escape its scope is arguably the most important part of the error message, so if this is reverted, that line should probably be moved before the type mismatch. Especially in cases like this withrunST
, the type mismatch is not very meaningful without that piece of information.For example:
The text was updated successfully, but these errors were encountered: