At first I thought it is a bug, but after reading some issues I got to think that it is a feature. Nevertheless, instead of filing a bug/CR I decided to ask first.
As in title: the compiler infers less polymorphism for local bindings as opposed to top-level bindings. For example, this code compiles:
deleteAt' idx arr = fromMaybe arr $ deleteAt idx arr
main = do
logShow $ deleteAt' 0 [1,2,3]
logShow $ deleteAt' 1 ["Ala", "ma", "kota"]
and this does not:
main = do
logShow $ deleteAt' 0 [1,2,3]
logShow $ deleteAt' 1 ["Ala", "ma", "kota"]
where
deleteAt' idx arr = fromMaybe arr $ deleteAt idx arr
(Could not match type String with Int
). It works only after explicitly giving it a polymorphic type signature. Is it a deliberate behaviour?