小编Mar*_*rio的帖子

F#中的变形

我正在阅读关于catamorphisms的维基百科文章,目前我能够在F#中重现Haskell示例,除了这部分:

type Algebra f a = f a -> a -- the generic f-algebras

newtype Fix f = Iso { invIso :: f (Fix f) } -- gives us the initial algebra for the functor f

cata :: Functor f => Algebra f a -> (Fix f -> a) -- catamorphism from Fix f to a
cata alg = alg . fmap (cata alg) . invIso -- note that invIso and alg map in opposite directions
Run Code Online (Sandbox Code Playgroud)

这可能在F#中做到吗?

f# haskell catamorphism

13
推荐指数
1
解决办法
430
查看次数

标签 统计

catamorphism ×1

f# ×1

haskell ×1