module Fp072 where
import Control.Monad.Instances
import Control.Applicative
import Data.Monoid
import qualified Data.Foldable as F
import Control.Monad.Writer

data Tree a = Leaf a | Branch (Tree a) a (Tree a) 
  deriving Show

instance Functor Tree where
  fmap g (Leaf x)       = Leaf (g x)
  fmap g (Branch l x r) = Branch (fmap g l) (g x) (fmap g r)



-- Аппликативные функторы

fs :: [Integer -> Integer]
fs = [\x->2*x, \x->3+x, \x->4-x]

as :: [Integer]
as = [1,2]

-- *Fp072> getZipList $ ZipList fs <*> ZipList as
-- [2,5]

-- *Fp072> fs <*> as
-- [2,4,4,5,3,2]

