Closed jlrwi closed 5 years ago
using id
in traverse means the traversable already has values of type f b
in it. for example if you have Array (Maybe Int)
and use traverse
with id
you would get Maybe (Array int)
That was the clue that helped me undo the knot in my brain. (After several more hours of puzzling.) Thanks!
The Composition law for Traversable uses the identity function (x => x) as an argument where a function of type a -> f b is expected. This has me confused - using F.of or G.of to lift the value into the desired Applicative would fit the type signature, but that's not how it's written.
I'm trying to educate myself by implementing traverse for simple types like Identity and Maybe, and I'm not sure if my implementation of traverse is wrong, or if my implementation of the test is wrong, or both.