Recursion Schemes in Agda

后端 未结 1 1702
陌清茗
陌清茗 2021-02-13 23:04

Needless to say, the standard construction in Haskell

newtype Fix f = Fix { getFix :: f (Fix f) }

cata :: (Functor f) => (f a -> a) -> Fix f -> a
ca         


        
相关标签:
1条回答
  • 2021-02-13 23:30

    You'll find such a development (over a restricted universe of functors) in Ulf Norell's canonical Agda tutorial!

    Unfortunately not all the usual recursion schemes can really be encoded because all the "destructiony" ones consume data and all the "constructiony" ones produce codata, so the notion of feeding one into the other is necessarily partial. You could probably do it all in the partiality monad but that's rather unsatisfactory. That is more or less what the categorists are doing when they say that Haskell's "true category" is CPO⊥ though, because its initial algebras and terminal coalgebras coincide.

    0 讨论(0)
提交回复
热议问题