tag:blogger.com,1999:blog-3857512306503018420.post1458009480450343029..comments2015-02-16T08:33:54.327+00:00Comments on Nattermorphisms: Unfolding with View PatternsBenhttp://www.blogger.com/profile/05535385464025706733noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-3857512306503018420.post-31781029537159264652012-06-16T15:43:51.338+01:002012-06-16T15:43:51.338+01:00Actually, I think the standard presentation is mor...Actually, I think the standard presentation is more like Oleksandr's abstracting and using the base functor directly.<br /><br />It's the View Pattern way of looking at the underlying categorical duality that I was trying to draw attention to.Benhttp://www.blogger.com/profile/05535385464025706733noreply@blogger.comtag:blogger.com,1999:blog-3857512306503018420.post-68542057320859937122012-06-16T03:37:47.055+01:002012-06-16T03:37:47.055+01:00This is, in fact, the standard presentation of cat...This is, in fact, the standard presentation of cata-/anamorphisms, and is why we call them duals of one another. Note that there's also a change from using the least fixed-point (in cata) and the greatest fixed-point (in ana); these two fixedpoints just happen to coincide in Haskell.<br /><br />That foldr/unfoldr have the types they do is mostly just to make things look simpler by compiling away the intermediate data structures.winterkoninkjehttp://winterkoninkje.dreamwidth.org/noreply@blogger.comtag:blogger.com,1999:blog-3857512306503018420.post-42272974042782390872012-06-15T10:39:15.142+01:002012-06-15T10:39:15.142+01:00Neat! Also generalizes to arbitrary catamorphisms...Neat! Also generalizes to arbitrary catamorphisms / anamorphisms:<br /><br />Fix f = In { out :: f (Fix f) }<br /><br />cata :: (f a -> a) -> Fix f -> a<br />cata f (In x) = f $ fmap (cata f) x<br /><br />ana :: (a -> f a) -> a -> Fix f<br />ana f (f -> (fmap (ana f) -> x)) = In xOleksandr Manzyukhttp://www.blogger.com/profile/12871948425425864333noreply@blogger.com