Created
March 27, 2016 18:50
-
-
Save amitaibu/4a77b7452db9d7ef016d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Page: 689 | |
module Applicatives where | |
import Control.Applicative | |
import Data.Monoid | |
import Test.QuickCheck | |
import Test.QuickCheck.Checkers | |
import Test.QuickCheck.Classes | |
take' :: Int -> List a -> List a | |
take' = undefined | |
data List a = | |
Nil | |
| Cons a (List a) | |
deriving (Eq, Show) | |
newtype ZipList' a = | |
ZipList' (List a) | |
deriving (Eq, Show) | |
instance Functor List where | |
fmap _ Nil = Nil | |
fmap f (Cons a a') = Cons (f a) (fmap f a') | |
instance Applicative List where | |
pure a = (Cons a Nil) | |
_ <*> Nil = Nil | |
Nil <*> _ = Nil | |
(Cons f fs) <*> (Cons a as) = Cons (f a) (fs <*> as) | |
instance Eq a => EqProp (ZipList' a) where | |
xs =-= ys = xs' `eq` ys' | |
where xs' = let (ZipList' l) = xs | |
in take' 3000 l | |
ys' = let (ZipList' l) = ys | |
in take' 3000 l | |
instance Functor ZipList' where | |
fmap f (ZipList' xs) = ZipList' $ fmap f xs | |
instance Applicative ZipList' where | |
pure = undefined | |
(<*>) = undefined |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment