{-# LANGUAGE DeriveGeneric #-}
module Distribution.Solver.Types.SolverId
    ( SolverId(..)
    )

where

import Distribution.Solver.Compat.Prelude
import Prelude ()

import Distribution.Package (PackageId, Package(..), UnitId)

-- | The solver can produce references to existing packages or
-- packages we plan to install.  Unlike 'ConfiguredId' we don't
-- yet know the 'UnitId' for planned packages, because it's
-- not the solver's job to compute them.
--
data SolverId = PreExistingId { SolverId -> PackageId
solverSrcId :: PackageId, SolverId -> UnitId
solverInstId :: UnitId }
              | PlannedId     { solverSrcId :: PackageId }
  deriving (SolverId -> SolverId -> Bool
(SolverId -> SolverId -> Bool)
-> (SolverId -> SolverId -> Bool) -> Eq SolverId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SolverId -> SolverId -> Bool
$c/= :: SolverId -> SolverId -> Bool
== :: SolverId -> SolverId -> Bool
$c== :: SolverId -> SolverId -> Bool
Eq, Eq SolverId
Eq SolverId
-> (SolverId -> SolverId -> Ordering)
-> (SolverId -> SolverId -> Bool)
-> (SolverId -> SolverId -> Bool)
-> (SolverId -> SolverId -> Bool)
-> (SolverId -> SolverId -> Bool)
-> (SolverId -> SolverId -> SolverId)
-> (SolverId -> SolverId -> SolverId)
-> Ord SolverId
SolverId -> SolverId -> Bool
SolverId -> SolverId -> Ordering
SolverId -> SolverId -> SolverId
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 :: SolverId -> SolverId -> SolverId
$cmin :: SolverId -> SolverId -> SolverId
max :: SolverId -> SolverId -> SolverId
$cmax :: SolverId -> SolverId -> SolverId
>= :: SolverId -> SolverId -> Bool
$c>= :: SolverId -> SolverId -> Bool
> :: SolverId -> SolverId -> Bool
$c> :: SolverId -> SolverId -> Bool
<= :: SolverId -> SolverId -> Bool
$c<= :: SolverId -> SolverId -> Bool
< :: SolverId -> SolverId -> Bool
$c< :: SolverId -> SolverId -> Bool
compare :: SolverId -> SolverId -> Ordering
$ccompare :: SolverId -> SolverId -> Ordering
$cp1Ord :: Eq SolverId
Ord, (forall x. SolverId -> Rep SolverId x)
-> (forall x. Rep SolverId x -> SolverId) -> Generic SolverId
forall x. Rep SolverId x -> SolverId
forall x. SolverId -> Rep SolverId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SolverId x -> SolverId
$cfrom :: forall x. SolverId -> Rep SolverId x
Generic)

instance Binary SolverId
instance Structured SolverId

instance Show SolverId where
    show :: SolverId -> String
show = PackageId -> String
forall a. Show a => a -> String
show (PackageId -> String)
-> (SolverId -> PackageId) -> SolverId -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SolverId -> PackageId
solverSrcId

instance Package SolverId where
  packageId :: SolverId -> PackageId
packageId = SolverId -> PackageId
solverSrcId