[Haskell-beginners] Applicative on Tree
Mike Houghton
mike_k_houghton at yahoo.co.uk
Mon Sep 7 19:59:18 UTC 2015
Hi,
I’m looking at
data Tree a = Node a [Tree a] deriving (Show)
and trying to write the Applicative instance.
I have I think a correct Functor :
instance Functor (Tree) where
fmap f (Node x tr) = Node (f x) ( fmap (fmap f) tr)
but I’m well and truly stuck on Applicative :)
I have
instance Applicative (Tree) where
pure x = Node x []
(Node f []) <*> tr = fmap f tr
(Node f fs) <*> tr@(Node x xs) = ?????
I cant get rid of the question marks! :)
any pointers would be really appreciated!
Thanks
More information about the Beginners
mailing list