Reputation: 360
let updateFunc = updatedMaybeProperty srcTitle targetTitle :: (Title -> Maybe a) -> Maybe a
_ = updateFunc (titleVersion :: Title -> Maybe Text)
_ = updateFunc (titleYearProduced :: Title -> Maybe Integer)
I get this error in line 3:
• Couldn't match type ‘Text’ with ‘Integer’
Expected type: Title -> Maybe Text
Actual type: Title -> Maybe Integer
• In the first argument of ‘updateFunc’, namely
‘(titleYearProduced :: Title -> Maybe Integer)’
Apparently, in line 2, the compiler infers the type for Maybe a
and decides a
must always be Text
.
How can I prevent this and make updateFunc
"generic" so that it works with different types for a
?
Upvotes: 0
Views: 82
Reputation: 116139
Try annotating the binding, not the expression.
let updateFunc :: (Title -> Maybe a) -> Maybe a
updateFunc = updatedMaybeProperty srcTitle targetTitle
_ = updateFunc (titleVersion :: Title -> Maybe Text)
_ = updateFunc (titleYearProduced :: Title -> Maybe Integer)
Upvotes: 6