Fix new game resize bug
This commit is contained in:
@@ -3,6 +3,7 @@ Combining and composing trees with 'Either' nodes.
|
||||
-}
|
||||
module Dodge.Layout.Tree.Either
|
||||
( expandTreeBy
|
||||
, appendEitherTree
|
||||
, connectRoom
|
||||
, deadRoom
|
||||
) where
|
||||
@@ -20,6 +21,16 @@ expandTreeBy f (Node x xs) = appendAndRemove $ f x
|
||||
appendAndRemove (Node (Left y) ys) = Node y (map appendAndRemove ys)
|
||||
appendAndRemove (Node (Right y) _ ) = Node y (map (expandTreeBy f) xs)
|
||||
|
||||
-- | Appends a second either forest at the 'Right' elements of a first either
|
||||
-- tree.
|
||||
-- Makes such 'Right' elements into 'Left's.
|
||||
appendEitherTree
|
||||
:: Tree (Either a a) -- ^ The first tree
|
||||
-> [Tree (Either a a)] -- ^ The forest to append
|
||||
-> Tree (Either a a)
|
||||
appendEitherTree (Node (Left x) ts) ts' = Node (Left x) $ map (flip appendEitherTree ts') ts
|
||||
appendEitherTree (Node (Right x) ts) ts' = Node (Left x) ts'
|
||||
|
||||
removeEither (Left y) = y
|
||||
removeEither (Right y) = y
|
||||
|
||||
|
||||
Reference in New Issue
Block a user