Re:Continued Fractions in Haskell
by Y_Y on Wednesday April 21, 2021 @09:24AM
(#26889337)
Monadic anamorphisms
[ Parent
| on HN ]
Re:Continued Fractions in Haskell
by yakshaving_jgt on Wednesday April 21, 2021 @10:06AM
(#26889864)
Are you suggesting monadic anamorphisms are easy in other languages but hard in Haskell? Could you give an example for comparison?
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