but trying to return an empty map from a function generates an error:
let fn = () => Belt.Map.String.empty
/* or even having this as a body of the function
{
let emptyMap = Belt.Map.String.empty
emptyMap
}
*/
let y = fn()
This expression's type contains type variables that can't be generalized:
Belt.Map.String.t<'_weak1>
This happens when the type system senses there's a mutation/side-effect,
in combination with a polymorphic value.
Using or annotating that value usually solves it.
For anyone curious as to why this happens, it’s because the type error is only triggered for values that are exported. When you shadow a binding, then the original binding is no longer exported.