-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolour.hs
85 lines (73 loc) · 2.61 KB
/
colour.hs
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
{-# LANGUAGE DeriveDataTypeable, StandaloneDeriving #-} -- for GHC < 7.10
import Test.Speculate
import Test.Speculate.Utils.Colour
import Data.Ratio
import Data.Function (on)
deriving instance Typeable Colour -- for GHC < 7.10
-- Just for Listable.tiers enumeration
data ColourComponent = ColourComponent Rational
instance Listable ColourComponent where
tiers = mapT (ColourComponent . uncurry (%))
$ tiers `suchThat` (\(n,d) -> n >= 0 && d > 0 && n <= d && n `gcd` d == 1)
`ofWeight` 0
instance Listable Colour where
tiers = cons3 (\(ColourComponent r) (ColourComponent g) (ColourComponent b) -> RGB r g b)
instance Name Colour where name _ = "c"
colour :: Colour
colour = undefined
main :: IO ()
main = speculate args
{ instances =
[ mkOrdLessEqual ((<=) `on` lightness)
, reifyInstances colour
]
, maxSize = 4
, maxSemiSize = 2
, force = True
, constants =
[ constant "+" $ (+) -:> colour
, constant "-" $ (-) -:> colour
-- , constant "*" $ (*) -:> colour
-- , constant "negate" $ negate -:> colour
-- , constant ".+." $ (.+.) -:> colour
-- , constant ".-." $ (.-.) -:> colour
-- , constant ".*." $ (.*.) -:> colour
, constant "chroma" chroma
, constant "hue" hue
, constant "saturation" saturation
-- , constant "intensity" intensity
, constant "value" value
, constant "lightness" lightness
, constant "fromHSV" fromHSV
, constant "fromHSL" fromHSL
, constant "mix" mix
-- , constant "mixHSV" mixHSV
, background
, constant "black" black
, constant "white" white
, constant "red" red
, constant "grey" grey
, constant "green" green
, constant "blue" blue
-- , constant "cyan" cyan
-- , constant "magenta" magenta
-- , constant "yellow" yellow
-- , constant "orange" orange
, constant "Just" $ Just -:> rational
, constant "Nothing" (Nothing :: Maybe Rational)
, showConstant (0 % 1 :: Rational)
, showConstant (1 % 1 :: Rational)
, showConstant (1 % 2 :: Rational)
-- , constant "%" $ (%) -:> integer
-- , constant "<=" $ (<=) -:> rational
-- , constant "<" $ (<) -:> rational
-- , constant "==" $ (==) -:> colour
-- , constant "/=" $ (/=) -:> colour
-- , constant "isGrey" isGrey
-- , constant "notGrey" notGrey
-- , constant "primary" primary
-- , constant "secondary" secondary
-- , constant "tertiary" tertiary
-- , constant "`isOppositeTo`" isOppositeTo
]
}