我正在尝试构建以下递归方案:
{-# LANGUAGE DeriveFunctor #-}
import Data.Functor.Foldable
import Control.Comonad
import Control.Comonad.Cofree
data Term a = Str String | Array [a] deriving (Show, Functor)
type Tree = Fix Term
type Annotated = Cofree Term String
-- i.e. Annotated = String × Term Annotated
something :: (Term String -> String) -> Tree -> Annotated
something algebra = cata algebra' where
algebra' t = algebra (extract <$> t) :< t
如何something
使用现代递归方案库中的常用函数,例如recursion-schemes
?这个计划有一个众所周知的名字吗?