I was experimenting on implementing a Red Black Tree.
As I learned more about Red black trees enough that I felt I had a good grasp on it I decided to use an established package and perhaps implement a Red black tree as a seperate project
DOJ7WIUNOWLMXFIGXUDM2XXP4FANRC7XHP6P2ZZOV6JOTGHO5M2QC
66SF6NA6WQF5U3B3CP2QWMCAZUL5DLQI3ASE2EOKCLTEU4PXHDSQC
WILCC2NZDLTXRZADOLY2I4O2UP4BC7ZA7G7PFWXZAXUNRSBUS4AQC
GNENKYVZNZHP7ZH624LVZ7HJUHFNEG5CHPJNY3IUBTWDSXQ3YFIAC
4QPDDW46NZLFA2GZ4YFOLEMHHP5BPHLBOTSZMOJ3UMGRQ4DH3N7QC
B2JWXIEPCMVVITDJDR2SACY4VHITXGH7ZM6A5RWN6E7OKTO43TUAC
O35UMQTSQPBNLYTXGBZOVCRNDQTCG2KDF2SJNRFJSZT5J2LJJ5OAC
remove' :: forall a. (Ord a) => TreeZipper a -> RedBlackTree a
removeSimple :: forall a. (Ord a) => TreeZipper a -> RedBlackTree a
removeSimple = fromZipper . go
where
go :: TreeZipper a -> TreeZipper a
go zip@([], Node c node@(Node {}) v r@(Node {})) = undefined
-- let leftMost = min $ toZipper r
-- leftMod = modify (const Leaf) leftMost
-- rootSubTree = fromZipper leftMod
-- switch = modify (const (Node lc node left rootSubTree)) zip
-- in upMost leftMost
go z = remove' z
min :: TreeZipper a -> TreeZipper a
min (path, node@(Node _ Leaf _ _)) = (path, node)
min zipper = min $ left zipper
withChild :: RedBlackTree a -> Bool
withChild (Node _ (Node {}) _ _) = True
withChild (Node _ _ _ (Node {})) = True
withChild _ = False
isColor :: Color -> RedBlackTree a -> Bool
isColor color (Node c _ _ _) = c == color
isColor color Leaf = color == Black
withoutChildAndBlack :: RedBlackTree a -> Bool
withoutChildAndBlack = (isColor Black &&& (not . withChild)) >>> Arrow.arr (uncurry (&&))
remove' :: forall a. (Ord a) => TreeZipper a -> TreeZipper a