File: Arbitrary.hs

package info (click to toggle)
ghc 8.0.1-17
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 55,080 kB
  • ctags: 9,332
  • sloc: haskell: 363,120; ansic: 54,900; sh: 4,782; makefile: 974; perl: 542; asm: 315; python: 306; xml: 154; lisp: 7
file content (63 lines) | stat: -rw-r--r-- 1,913 bytes parent folder | download
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}

module Arbitrary where

import Test.QuickCheck

import qualified Data.ByteString as B
import qualified Data.ByteString.Lazy as L
#if MIN_VERSION_bytestring(0,10,4)
import qualified Data.ByteString.Short as S
#endif

instance Arbitrary L.ByteString where
  arbitrary = fmap L.fromChunks arbitrary

instance Arbitrary B.ByteString where
  arbitrary = B.pack `fmap` arbitrary

#if MIN_VERSION_bytestring(0,10,4)
instance Arbitrary S.ShortByteString where
  arbitrary = S.toShort `fmap` arbitrary
#endif

instance (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e,
          Arbitrary f) =>
         Arbitrary (a,b,c,d,e,f) where
  arbitrary = do
    (a,b,c,d,e) <- arbitrary
    f <- arbitrary
    return (a,b,c,d,e,f)

instance (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e,
          Arbitrary f, Arbitrary g) =>
         Arbitrary (a,b,c,d,e,f,g) where
  arbitrary = do
    (a,b,c,d,e) <- arbitrary
    (f,g) <- arbitrary
    return (a,b,c,d,e,f,g)

instance (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e,
          Arbitrary f, Arbitrary g, Arbitrary h) =>
         Arbitrary (a,b,c,d,e,f,g,h) where
  arbitrary = do
    (a,b,c,d,e) <- arbitrary
    (f,g,h) <- arbitrary
    return (a,b,c,d,e,f,g,h)

instance (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e,
          Arbitrary f, Arbitrary g, Arbitrary h, Arbitrary i) =>
         Arbitrary (a,b,c,d,e,f,g,h,i) where
  arbitrary = do
    (a,b,c,d,e) <- arbitrary
    (f,g,h,i) <- arbitrary
    return (a,b,c,d,e,f,g,h,i)

instance (Arbitrary a, Arbitrary b, Arbitrary c, Arbitrary d, Arbitrary e,
          Arbitrary f, Arbitrary g, Arbitrary h, Arbitrary i, Arbitrary j) =>
         Arbitrary (a,b,c,d,e,f,g,h,i,j) where
  arbitrary = do
    (a,b,c,d,e) <- arbitrary
    (f,g,h,i,j) <- arbitrary
    return (a,b,c,d,e,f,g,h,i,j)