{- Setup DO NOT CHANGE -} {-# LANGUAGE CPP #-} module Exercise_8_Sol_Tree (Tree, delete, insert, update) where #ifdef Testing import Tree (Tree, modify) #else import Exercise_8_Sol (Tree, modify) #endif {- End Setup -} insert :: Ord a => b -> a -> Tree (a,b) -> Tree (a,b) insert = modify . const . Just update :: Ord a => (b -> b) -> a -> Tree (a,b) -> Tree (a,b) update = modify . maybeMap where maybeMap _ Nothing = Nothing maybeMap f (Just x) = Just (f x) delete :: Ord a => a -> Tree (a,b) -> Tree (a,b) delete = modify (const Nothing)