While working on some logic on my current project, I came across a weird situation, where I have two functions with the same signature, one existing outside the context of a third function (“filterOutside”), and the second within that same context (“filterWithParam”).
The issue is as follows. When using the first example, using the outside function in the filter, I can correctly use it on both TextMaps as the the signature of the “filterForKei” function remains generic. In the second example, using the param function in the filter, I cannot use the “filterForKey” function in both TextMaps, as the function signature infers the first TextMap.
I would like to know what is causing this, as it is a bit confusing.
filterOutside : Text -> Bool filterOutside _ = True testFunc : (Text -> Bool) -> Text testFunc filterWithParam = "" where textMap1 : TextMap Int = fromList [("Test", 1)] textMap2 : TextMap (Int, Int) = fromList [("Test", (1, 2))] -- Filter using outside function filterForKei = filterWithKey (const . filterOutside) filtered1 = filterForKei textMap1 filtered2 = filterForKei textMap2 -- Filter using param function filterForKey = filterWithKey (const . filterWithParam) filtered3 = filterForKey textMap1 filtered4 = filterForKey textMap2