module Data.Colour.Chan where
import qualified Data.List (sum)
newtype Chan p a = Chan a deriving (Chan p a -> Chan p a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall p a. Eq a => Chan p a -> Chan p a -> Bool
/= :: Chan p a -> Chan p a -> Bool
$c/= :: forall p a. Eq a => Chan p a -> Chan p a -> Bool
== :: Chan p a -> Chan p a -> Bool
$c== :: forall p a. Eq a => Chan p a -> Chan p a -> Bool
Eq)
empty :: (Num a) => Chan p a
empty :: forall a p. Num a => Chan p a
empty = forall p a. a -> Chan p a
Chan a
0
full :: (Num a) => Chan p a
full :: forall a p. Num a => Chan p a
full = forall p a. a -> Chan p a
Chan a
1
scale :: (Num a) => a -> Chan p a -> Chan p a
scale :: forall a p. Num a => a -> Chan p a -> Chan p a
scale a
s (Chan a
x) = forall p a. a -> Chan p a
Chan (a
sforall a. Num a => a -> a -> a
*a
x)
add :: (Num a) => Chan p a -> Chan p a -> Chan p a
(Chan a
a) add :: forall a p. Num a => Chan p a -> Chan p a -> Chan p a
`add` (Chan a
b) = forall p a. a -> Chan p a
Chan (a
aforall a. Num a => a -> a -> a
+a
b)
invert :: (Num a) => Chan p a -> Chan p a
invert :: forall a p. Num a => Chan p a -> Chan p a
invert (Chan a
a) = forall p a. a -> Chan p a
Chan (a
1forall a. Num a => a -> a -> a
-a
a)
over :: Chan p a -> a -> Chan p a -> Chan p a
over Chan p a
c0 a
a Chan p a
c1 = Chan p a
c0 forall a p. Num a => Chan p a -> Chan p a -> Chan p a
`add` forall a p. Num a => a -> Chan p a -> Chan p a
scale (a
1forall a. Num a => a -> a -> a
-a
a) Chan p a
c1
convert :: (Fractional b, Real a) => Chan p a -> Chan p b
convert :: forall b a p. (Fractional b, Real a) => Chan p a -> Chan p b
convert (Chan a
x) = forall p a. a -> Chan p a
Chan (forall a b. (Real a, Fractional b) => a -> b
realToFrac a
x)
sum :: (Num a) => [Chan p a] -> Chan p a
sum :: forall a p. Num a => [Chan p a] -> Chan p a
sum [Chan p a]
l = forall p a. a -> Chan p a
Chan (forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
Data.List.sum [a
x |Chan a
x <- [Chan p a]
l])