4 ms·
Where does haskell fit on this paradigm? You can derive "internal" iterators using Traversable but it's not like zip is difficult to implement.
by nimish 13y ago
Where does haskell fit on this paradigm?
You can derive "internal" iterators using Traversable but it's not like zip is difficult to implement.
- pcwalton 13y agoHaskell typically uses internal iterators, but because it's lazy many composition strategies are more straightforward. Rust is strict, however, so the same techniques don't apply.
- koomi 13y agoThere is no general zip for every Traversable, though there is one for every Applicative with a suitable instance (like the ZipList wrapper for lists): liftA2 (,) The reason is that you need to operate on multiple containers at once and that is what Applicative's (<*>) provides, while Traversable only requires Functor and can therefore only traverse one container at a time. So what Haskell has is just internal iteration, but we have another interface for internal iteration on multiple containers that allows zip to be implemented easily.