diff options
author | Joe Zhao <ztuowen@gmail.com> | 2015-03-26 01:47:10 +0800 |
---|---|---|
committer | Joe Zhao <ztuowen@gmail.com> | 2015-03-26 01:47:10 +0800 |
commit | 36a645180f3ef13126c06b957d76c729f62d41fd (patch) | |
tree | 98658a7823bf3ccf3828f460dde85a694ba730a8 /applicative/h2.hs | |
parent | 934eda548d1f0260db095f2739b2211bd5157324 (diff) | |
download | typeclass-36a645180f3ef13126c06b957d76c729f62d41fd.tar.gz typeclass-36a645180f3ef13126c06b957d76c729f62d41fd.tar.bz2 typeclass-36a645180f3ef13126c06b957d76c729f62d41fd.zip |
applicative h1 h2
Diffstat (limited to 'applicative/h2.hs')
-rw-r--r-- | applicative/h2.hs | 10 |
1 files changed, 10 insertions, 0 deletions
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) |