{-# LANGUAGE NoImplicitPrelude #-}
module Stack.Types.Dependency
( DepValue (..)
, DepType (..)
) where
import Distribution.Types.VersionRange ( VersionRange )
import Stack.Prelude
import Stack.Types.Version ( intersectVersionRanges )
data DepValue = DepValue
{ DepValue -> VersionRange
dvVersionRange :: !VersionRange
, DepValue -> DepType
dvType :: !DepType
}
deriving (Int -> DepValue -> ShowS
[DepValue] -> ShowS
DepValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DepValue] -> ShowS
$cshowList :: [DepValue] -> ShowS
show :: DepValue -> String
$cshow :: DepValue -> String
showsPrec :: Int -> DepValue -> ShowS
$cshowsPrec :: Int -> DepValue -> ShowS
Show, Typeable)
instance Semigroup DepValue where
DepValue VersionRange
a DepType
x <> :: DepValue -> DepValue -> DepValue
<> DepValue VersionRange
b DepType
y = VersionRange -> DepType -> DepValue
DepValue (VersionRange -> VersionRange -> VersionRange
intersectVersionRanges VersionRange
a VersionRange
b) (DepType
x forall a. Semigroup a => a -> a -> a
<> DepType
y)
data DepType = AsLibrary | AsBuildTool
deriving (Int -> DepType -> ShowS
[DepType] -> ShowS
DepType -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DepType] -> ShowS
$cshowList :: [DepType] -> ShowS
show :: DepType -> String
$cshow :: DepType -> String
showsPrec :: Int -> DepType -> ShowS
$cshowsPrec :: Int -> DepType -> ShowS
Show, DepType -> DepType -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DepType -> DepType -> Bool
$c/= :: DepType -> DepType -> Bool
== :: DepType -> DepType -> Bool
$c== :: DepType -> DepType -> Bool
Eq)
instance Semigroup DepType where
DepType
AsLibrary <> :: DepType -> DepType -> DepType
<> DepType
_ = DepType
AsLibrary
DepType
AsBuildTool <> DepType
x = DepType
x