Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

EnvT use case

View gist:4967054
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
import Data.Tree
import Control.Comonad
import Control.Comonad.Trans.Class
import Control.Comonad.Trans.Env
 
replusify:: MonadPlus m => [a] -> m a
replusify = msum . map return
 
class Treeish l where
children :: MonadPlus m => l -> m l
descendants :: MonadPlus m => l -> m l
 
instance Treeish (Tree a) where
children = replusify . subForest
descendants = replusify . flatten . duplicate
 
instance Treeish (EnvT e Tree a) where
children = replusify . map rootLabel . subForest . lower . duplicate
descendants = replusify . flatten . lower . duplicate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.