    {-# LANGUAGE DeriveFunctor #-}
    module Distribution.Solver.Modular.Var (
        Var(..)
      , showVar
      , varPN
      ) where

    import Prelude hiding (pi)

    import Distribution.Solver.Modular.Flag
    import Distribution.Solver.Types.PackagePath

    {-------------------------------------------------------------------------------
      Variables
    -------------------------------------------------------------------------------}

    -- | The type of variables that play a role in the solver.
    -- Note that the tree currently does not use this type directly,
    -- and rather has separate tree nodes for the different types of
    -- variables. This fits better with the fact that in most cases,
    -- these have to be treated differently.
    data Var qpn = P qpn | F (FN qpn) | S (SN qpn)
      deriving (Var qpn -> Var qpn -> Bool
    (Var qpn -> Var qpn -> Bool)
    -> (Var qpn -> Var qpn -> Bool) -> Eq (Var qpn)
    forall qpn. Eq qpn => Var qpn -> Var qpn -> Bool
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    $c== :: forall qpn. Eq qpn => Var qpn -> Var qpn -> Bool
    == :: Var qpn -> Var qpn -> Bool
    $c/= :: forall qpn. Eq qpn => Var qpn -> Var qpn -> Bool
    /= :: Var qpn -> Var qpn -> Bool
    Eq, Eq (Var qpn)
    Eq (Var qpn) =>
    (Var qpn -> Var qpn -> Ordering)
    -> (Var qpn -> Var qpn -> Bool)
    -> (Var qpn -> Var qpn -> Bool)
    -> (Var qpn -> Var qpn -> Bool)
    -> (Var qpn -> Var qpn -> Bool)
    -> (Var qpn -> Var qpn -> Var qpn)
    -> (Var qpn -> Var qpn -> Var qpn)
    -> Ord (Var qpn)
    Var qpn -> Var qpn -> Bool
    Var qpn -> Var qpn -> Ordering
    Var qpn -> Var qpn -> Var qpn
    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
    forall qpn. Ord qpn => Eq (Var qpn)
    forall qpn. Ord qpn => Var qpn -> Var qpn -> Bool
    forall qpn. Ord qpn => Var qpn -> Var qpn -> Ordering
    forall qpn. Ord qpn => Var qpn -> Var qpn -> Var qpn
    $ccompare :: forall qpn. Ord qpn => Var qpn -> Var qpn -> Ordering
    compare :: Var qpn -> Var qpn -> Ordering
    $c< :: forall qpn. Ord qpn => Var qpn -> Var qpn -> Bool
    < :: Var qpn -> Var qpn -> Bool
    $c<= :: forall qpn. Ord qpn => Var qpn -> Var qpn -> Bool
    <= :: Var qpn -> Var qpn -> Bool
    $c> :: forall qpn. Ord qpn => Var qpn -> Var qpn -> Bool
    > :: Var qpn -> Var qpn -> Bool
    $c>= :: forall qpn. Ord qpn => Var qpn -> Var qpn -> Bool
    >= :: Var qpn -> Var qpn -> Bool
    $cmax :: forall qpn. Ord qpn => Var qpn -> Var qpn -> Var qpn
    max :: Var qpn -> Var qpn -> Var qpn
    $cmin :: forall qpn. Ord qpn => Var qpn -> Var qpn -> Var qpn
    min :: Var qpn -> Var qpn -> Var qpn
    Ord, Int -> Var qpn -> ShowS
    [Var qpn] -> ShowS
    Var qpn -> String
    (Int -> Var qpn -> ShowS)
    -> (Var qpn -> String) -> ([Var qpn] -> ShowS) -> Show (Var qpn)
    forall qpn. Show qpn => Int -> Var qpn -> ShowS
    forall qpn. Show qpn => [Var qpn] -> ShowS
    forall qpn. Show qpn => Var qpn -> String
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    $cshowsPrec :: forall qpn. Show qpn => Int -> Var qpn -> ShowS
    showsPrec :: Int -> Var qpn -> ShowS
    $cshow :: forall qpn. Show qpn => Var qpn -> String
    show :: Var qpn -> String
    $cshowList :: forall qpn. Show qpn => [Var qpn] -> ShowS
    showList :: [Var qpn] -> ShowS
    Show, (forall a b. (a -> b) -> Var a -> Var b)
    -> (forall a b. a -> Var b -> Var a) -> Functor Var
    forall a b. a -> Var b -> Var a
    forall a b. (a -> b) -> Var a -> Var b
    forall (f :: * -> *).
    (forall a b. (a -> b) -> f a -> f b)
    -> (forall a b. a -> f b -> f a) -> Functor f
    $cfmap :: forall a b. (a -> b) -> Var a -> Var b
    fmap :: forall a b. (a -> b) -> Var a -> Var b
    $c<$ :: forall a b. a -> Var b -> Var a
    <$ :: forall a b. a -> Var b -> Var a
    Functor)

    showVar :: Var QPN -> String
    showVar :: Var QPN -> String
    showVar (P QPN
    qpn) = QPN -> String
    showQPN QPN
    qpn
    showVar (F FN QPN
    qfn) = FN QPN -> String
    showQFN FN QPN
    qfn
    showVar (S SN QPN
    qsn) = SN QPN -> String
    showQSN SN QPN
    qsn

    -- | Extract the package name from a Var
    varPN :: Var qpn -> qpn
    varPN :: forall qpn. Var qpn -> qpn
    varPN (P qpn
    qpn)        = qpn
    qpn
    varPN (F (FN qpn
    qpn Flag
    _)) = qpn
    qpn
    varPN (S (SN qpn
    qpn Stanza
    _)) = qpn
    qpn