From 4e8118bfc0d10f3900f276e937ddc5ceea3010da Mon Sep 17 00:00:00 2001 From: Yuri Tatishchev Date: Mon, 23 Feb 2026 11:29:46 -0800 Subject: [PATCH] lab06: impl --- lab06/functors.lhs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lab06/functors.lhs b/lab06/functors.lhs index 58cc4d8..ad97e2a 100644 --- a/lab06/functors.lhs +++ b/lab06/functors.lhs @@ -3,6 +3,10 @@ > | Node v (Tree v) (Tree v) > deriving (Show) +> instance Functor Tree where +> fmap f (Node v left right) = Node (f v) (fmap f left) (fmap f right) +> fmap f Empty = Empty + The findT method shows how we may search through the tree to find a value. > findT :: Ord v => v -> Tree v -> Maybe v @@ -18,4 +22,3 @@ The findT method shows how we may search through the tree to find a value. Your job is to add support for fmap to this tree, so that the call to fmap below works: > main = print $ fmap (+1) (Node 3 (Node 1 Empty Empty) (Node 7 (Node 4 Empty Empty) Empty)) -