-
add
<$>
link:ch17_17.5_1.hs[role=include]
-
add
<$>
and<*>
, longer version ofliftA2
link:ch17_17.5_2.hs[role=include]
-
add
<$>
and<*>
, longer version ofliftA2
link:ch17_17.5_3.hs[role=include]
-
(Maybe Int, Maybe Int) → Maybe Int
usingSum
? dunnoWarningsomething is wrong here link:ch17_17.5_4.hs[role=include]
link:ch17_17.5_7.hs[role=include]
Warning
|
had to make somehow "limited" arbitrary, the infinite arbitrary is arbitrary = Cons <$> arbitrary <*> arbitrary and commented out
|
link:ch17_17.5_8.hs[role=include]
Note
|
the tests are taking a long time, compared to tests done so far |
link:ch17_17.5_9.hs[role=include]
Warning
|
doing something wrong here, what do mean "specialize and test in REPL"? some hint, example? |
-
[]
(pure :: (a -> [] a)) 4 [4] ((<*>) :: [] (a -> b) -> [] a -> [] b) [(+1)] [1] [2]
-
IO
(pure :: a -> IO a) "sdf" "sdf" ((<*>) :: IO (a -> b) -> IO a -> IO b) (return (+2)) (return 4) 6
-
(,) a
((pure :: Monoid b => a -> ((,) b) a) 4) :: (String, Int) ("",4) ((<*>) :: Monoid c => (,) c (a -> b) -> (,) c a -> (,) c b) ("sdf", (+4)) ("sdf", 7) ("sdfsdf",11)
-
(→) e
pure :: a -> ((->) e) a (<*>) :: ((->) e) (a -> b) -> ((->) e) a -> ((->) e) b
For all of those, you need also deriving Eq
so you can use quickcheck
-
newtype Identity a = Identity a deriving Show
link:ch17_17.9_1.hs[role=include]
-
data Pair a = Pair a a deriving Show
link:ch17_17.9_2.hs[role=include]
-
data Two a b = Two a b
link:ch17_17.9_3.hs[role=include]
-
data Three a b c = Three a b c
link:ch17_17.9_4.hs[role=include]
-
data Three' a b = Three' a b b
link:ch17_17.9_5.hs[role=include]
-
data Four a b c d = Four a b c d
link:ch17_17.9_6.hs[role=include]
-
data Four' a b = Four' a a a b
link:ch17_17.9_7.hs[role=include]