{-# LANGUAGE Safe #-}
module Types.Variance (
Variance(..),
allowsVariance,
composeVariance,
) where
data Variance =
Contravariant |
Covariant |
Invariant
deriving (Variance -> Variance -> Bool
(Variance -> Variance -> Bool)
-> (Variance -> Variance -> Bool) -> Eq Variance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Variance -> Variance -> Bool
$c/= :: Variance -> Variance -> Bool
== :: Variance -> Variance -> Bool
$c== :: Variance -> Variance -> Bool
Eq,Eq Variance
Eq Variance
-> (Variance -> Variance -> Ordering)
-> (Variance -> Variance -> Bool)
-> (Variance -> Variance -> Bool)
-> (Variance -> Variance -> Bool)
-> (Variance -> Variance -> Bool)
-> (Variance -> Variance -> Variance)
-> (Variance -> Variance -> Variance)
-> Ord Variance
Variance -> Variance -> Bool
Variance -> Variance -> Ordering
Variance -> Variance -> Variance
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Variance -> Variance -> Variance
$cmin :: Variance -> Variance -> Variance
max :: Variance -> Variance -> Variance
$cmax :: Variance -> Variance -> Variance
>= :: Variance -> Variance -> Bool
$c>= :: Variance -> Variance -> Bool
> :: Variance -> Variance -> Bool
$c> :: Variance -> Variance -> Bool
<= :: Variance -> Variance -> Bool
$c<= :: Variance -> Variance -> Bool
< :: Variance -> Variance -> Bool
$c< :: Variance -> Variance -> Bool
compare :: Variance -> Variance -> Ordering
$ccompare :: Variance -> Variance -> Ordering
$cp1Ord :: Eq Variance
Ord)
instance Show Variance where
show :: Variance -> String
show Variance
Contravariant = String
"contravariant"
show Variance
Invariant = String
"invariant"
show Variance
Covariant = String
"covariant"
composeVariance :: Variance -> Variance -> Variance
composeVariance :: Variance -> Variance -> Variance
composeVariance Variance
Covariant Variance
Covariant = Variance
Covariant
composeVariance Variance
Contravariant Variance
Contravariant = Variance
Covariant
composeVariance Variance
Contravariant Variance
Covariant = Variance
Contravariant
composeVariance Variance
Covariant Variance
Contravariant = Variance
Contravariant
composeVariance Variance
_ Variance
_ = Variance
Invariant
allowsVariance :: Variance -> Variance -> Bool
Variance
Covariant allowsVariance :: Variance -> Variance -> Bool
`allowsVariance` Variance
Covariant = Bool
True
Variance
Contravariant `allowsVariance` Variance
Contravariant = Bool
True
Variance
Invariant `allowsVariance` Variance
_ = Bool
True
Variance
_ `allowsVariance` Variance
_ = Bool
False