WILCC2NZDLTXRZADOLY2I4O2UP4BC7ZA7G7PFWXZAXUNRSBUS4AQC switchColor (Node Black l v r) = Node Red l v rswitchColor (Node Red l v r) = Node Black l v rswitchColor n = nnodeDirection :: TreeZipper a -> DirectionnodeDirection = fst . last . fstparent :: TreeZipper a -> TreeZipper aparent = upsibling :: TreeZipper a -> TreeZipper asibling node = case nodeDirection node ofL -> right . parent $ nodeR -> left . parent $ node
-- Maybe this is a candidate for GADTS?data Case a
distantNephew :: TreeZipper a -> TreeZipper adistantNephew z = case nodeDirection z ofL -> right . sibling $ zR -> left . sibling $ zcloseNephew :: TreeZipper a -> TreeZipper acloseNephew z = case nodeDirection z ofL -> left . sibling $ zR -> right . sibling $ zcolorOf :: RedBlackTree a -> ColorcolorOf Leaf = BlackcolorOf (Node c _ _ _) = cdata Case
[Red, Black, Black, Black] -> D4 (snd $ parent zipper) (snd $ sibling zipper)wherecolorOf Leaf = BlackcolorOf (Node c _ _ _) = courDirection = fst . last . fst $ zippersibling z = case ourDirection ofL -> right . parent $ zR -> left . parent $ zparent = updistant_nephew z = case ourDirection ofL -> right . sibling $ zR -> left . sibling $ zclose_nephew z = case ourDirection ofL -> left . sibling $ zR -> right . sibling $ z
[Red, Black, Black, Black] -> D4