3 ms·
I was being facetious, you can certainly do stuff like anamorphisms easily in other languages, but the hard work of pulling out and expressing the abstraction i
by Y_Y 6y ago
I was being facetious, you can certainly do stuff like anamorphisms easily in other languages, but the hard work of pulling out and expressing the abstraction is definitely a job for Haskell.
Anyway here's one from Data.Functor.Foldable.Exotic just for fun:
anaM :: (Corecursive t, Traversable (Base t), Monad m) => (a -> m (Base t a)) -> (a -> m t)
anaM psi = a where a = (fmap embed . traverse a) <=< psi