-
-
Save ChrisPenner/aa6083478d2d1100f62a974860aae529 to your computer and use it in GitHub Desktop.
Recursion schemes test
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
error: | |
• Couldn't match type ‘Base (Fix WindowF Bool)’ with ‘WindowF Bool’ | |
Expected type: Base (Fix WindowF Bool) Bool -> Bool | |
Actual type: WindowF Bool Bool -> Bool | |
• In the first argument of ‘cata’, namely ‘alg’ | |
In the expression: cata alg w | |
In an equation for ‘allActive’: | |
allActive (Window w) | |
= cata alg w | |
where | |
alg (Split _ _ l r) = l && r | |
alg (Single _ b) = b |
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
data Dir = Hor | |
| Vert | |
deriving (Show) | |
data WindowF r a = | |
Split Dir SplitInfo r r | |
| Single ViewInfo a | |
deriving (Show, Functor) | |
instance Bifunctor WindowF where | |
bimap f _g (Split dir si x y) = Split dir si (f x) (f y) | |
bimap _f g (Single vi a) = Single vi (g a) | |
newtype Window a = Window (Fix WindowF a) deriving Functor | |
allTree :: Window Bool -> Bool | |
allTree (Window w) = cata alg w | |
where | |
alg (Split _ _ x y) = x && y | |
alg (Single _ x) = x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment