Last active
February 12, 2019 21:13
-
-
Save kuribas/244c3d9958e645ea7f12ac9ea8eed010 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| {-# LANGUAGE DeriveFunctor #-} | |
| module Test where | |
| import Data.Functor.Foldable | |
| import Control.Monad.Free | |
| import qualified Control.Monad.Trans.Free as T | |
| data Tree t = Tree t t | |
| deriving Functor | |
| treeHeight :: (Free Tree a) -> Int | |
| treeHeight = cata heightAlg where | |
| heightAlg (T.Pure _) = 1 | |
| heightAlg (T.Free (Tree a b)) = max a b + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment