Created
April 5, 2019 20:22
-
-
Save ChrisPenner/379abb66cfb7b3a554aa61c5b0c49024 to your computer and use it in GitHub Desktop.
Dynamic Programming Comonads using Recursion Schemes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Data.Functor.Foldable | |
import Control.Comonad.Cofree as C | |
import Control.Comonad.Trans.Cofree as CF | |
cofreeDynExtend :: forall f a b. | |
Functor f | |
=> (CofreeF f a (C.Cofree f b) -> b) | |
-> C.Cofree f a | |
-> C.Cofree f b | |
cofreeDynExtend f = cata extract' | |
where | |
extract' :: CofreeF f a (C.Cofree f b) -> C.Cofree f b | |
extract' t@(_ CF.:< bs) = f t C.:< bs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment