Created
May 10, 2019 15:36
-
-
Save jship/666303a718e531390195f73ee9be4b93 to your computer and use it in GitHub Desktop.
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
printTree :: Show a => Tree a -> IO () | |
printTree = putStrLn . Tree.drawTree . fmap show | |
tree :: Tree Int | |
tree = Tree.unfoldTree buildNode 1 where | |
buildNode :: Int -> (Int, [Int]) | |
buildNode n | |
| 2 * n + 1 <= 7 = (n, [2 * n, 2 * n + 1]) | |
| otherwise = (n, []) | |
zipTest = zipper tree | |
& downward root | |
& focus .~ 42 | |
& rezip | |
zipTest' = zipper tree | |
& downward branches | |
& fromWithin traverse | |
& downward root | |
& rezip | |
tape = zipper tree | |
& downward branches | |
& fromWithin traverse | |
& downward root | |
& saveTape | |
tape' = zipper tree | |
& downward root | |
& saveTape | |
tapeTest :: IO (Tree Int) | |
tapeTest = do | |
t <- restoreTape tape tree | |
pure $ t | |
& focus .~ 99 | |
& rezip | |
tapeTest' :: IO (Tree Int) | |
tapeTest' = do | |
t <- restoreTape tape' tree | |
pure $ t | |
& focus .~ 42 | |
& rezip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment