x = Node x EmptyTree EmptyTree treeInsert :: (Ord a) => a -> Tree a -> Tree a treeInsert x EmptyTree = singleton x treeInsert x (Node y left right) | x == y = Node y left right -- ಉ͡ͳΒૠೖ͠ͳ͍ | x < y = Node y (treeInsert x left) right | x > y = Node y left (treeInsert x right)
EmptyTree = EmptyTree fmap f (Node x left right) = Node (f x) (fmap f left) (fmap f right) 4 Tree ܕίϯετϥΫλʢTree a ͕۩ମܕʣ 4 ҙɿҙͷؔΛద༻ͨ͠ޙೋ୳ࡧͷੑ࣭Λอͨ ͳ͍
f (Right x) = Right (f x) fmap f (Left x) = Left x 4 data Either a b = Left a | Right b 4 Left ͱ Right Ͱܕ͕ҧ͏͜ͱʹҙ 4 fmap Ͱద༻͢Δؔ f b -> c ܕ 4 Right ଆʹద༻Ͱ͖Δ͕ɺLeft ଆʹద༻Ͱ͖ͳ͍