-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbigTraversal.hs
More file actions
executable file
·39 lines (29 loc) · 1.15 KB
/
Copy pathbigTraversal.hs
File metadata and controls
executable file
·39 lines (29 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env cabal
{- cabal:
build-depends: base
, QuickCheck
, checkers
-}
import Test.QuickCheck (Arbitrary, arbitrary)
import Test.QuickCheck.Checkers
import Test.QuickCheck.Classes
data Big a b = Big a b b deriving (Eq, Show)
instance Functor (Big a) where
fmap f (Big x y z) = Big x (f y) (f z)
instance Foldable (Big a) where
foldMap f (Big x y z) = f y <> f z
-- foldr f ini (Big x y z) = f y $ f z ini
instance Traversable (Big a) where
traverse f (Big x y z) = Big x <$> f y <*> f z
instance (Eq a, Eq b) => EqProp (Big a b) where
(=-=) = eq
instance (Arbitrary a, Arbitrary b) => Arbitrary (Big a b) where
arbitrary = Big <$> arbitrary <*> arbitrary <*> arbitrary
main :: IO ()
main = do
quickBatch $ functor (undefined :: Big (String, Float, Int)
(String, Float, Int))
quickBatch $ foldable (undefined :: Big (Int, Float, String, Int, String)
(Int, Float, String, Int, String))
quickBatch $ traversable (undefined :: Big (String, String, String)
(String, String, String))