From 36a645180f3ef13126c06b957d76c729f62d41fd Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Thu, 26 Mar 2015 01:47:10 +0800 Subject: applicative h1 h2 --- applicative/h2.hs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 applicative/h2.hs (limited to 'applicative/h2.hs') diff --git a/applicative/h2.hs b/applicative/h2.hs new file mode 100644 index 0000000..6d9b801 --- /dev/null +++ b/applicative/h2.hs @@ -0,0 +1,10 @@ +import Control.Applicative + +newtype MyZipList a = MyZipList { getMyZipList :: [a] } + +instance Functor MyZipList where + fmap f (MyZipList x) = MyZipList (fmap f x) + +instance Applicative MyZipList where + pure x = MyZipList [x] + (MyZipList gs) <*> (MyZipList xs) = MyZipList (zipWith ($) gs xs) -- cgit v1.2.3-70-g09d2