
I have written a Wiki article where I argue, that Functor instances should match their arguments strictly in order to comply with the laws. However for the Traversable class I did not find laws, thus I invented one myself: sequenceA (fmap Identity x) == Identity x What do you think of it? Are there more laws that would be reasonable? http://www.haskell.org/haskellwiki/Lazy_functors

On 5 June 2011 11:28, Henning Thielemann
What do you think of it? Are there more laws that would be reasonable?
Jeremy Gibbons articulated a good set of laws, which unfortunately have not made their way into the documentation. See Section 5 of http://www.cs.ox.ac.uk/jeremy.gibbons/publications/iterator.pdf Paraphrasing, the laws are: 1. Identity (as you proposed): sequenceA . fmap Id = Id 2. Composition: sequenceA . fmap Comp = Comp . fmap sequenceA . sequenceA 3. Naturality. For "applicative functor transformation" phi, we have: sequenceA . fmap phi = phi ◦ sequenceA Where an applicative functor transformation phi :: m a -> n a is a function that respects: a) phi (pure a) = pure a b) phi (mf <*> mx) = phi mf <*> phi mx Cheers, Max
participants (2)
-
Henning Thielemann
-
Max Bolingbroke