
7 Sep
2015
7 Sep
'15
3:59 p.m.
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