{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE DeriveGeneric #-}

module Distribution.Client.Types.PackageLocation
  ( PackageLocation (..)
  , UnresolvedPkgLoc
  , ResolvedPkgLoc
  , UnresolvedSourcePackage
  ) where

import Distribution.Client.Compat.Prelude
import Prelude ()

import Network.URI (URI)

import Distribution.Types.PackageId (PackageId)

import Distribution.Client.Types.Repo
import Distribution.Client.Types.SourceRepo (SourceRepoMaybe)
import Distribution.Solver.Types.SourcePackage (SourcePackage)

type UnresolvedPkgLoc = PackageLocation (Maybe FilePath)

type ResolvedPkgLoc = PackageLocation FilePath

data PackageLocation local
  = -- | An unpacked package in the given dir, or current dir
    LocalUnpackedPackage FilePath
  | -- | A package as a tarball that's available as a local tarball
    LocalTarballPackage FilePath
  | -- | A package as a tarball from a remote URI
    RemoteTarballPackage URI local
  | -- | A package available as a tarball from a repository.
    --
    -- It may be from a local repository or from a remote repository, with a
    -- locally cached copy. ie a package available from hackage
    RepoTarballPackage Repo PackageId local
  | -- | A package available from a version control system source repository
    RemoteSourceRepoPackage SourceRepoMaybe local
  deriving (Int -> PackageLocation local -> ShowS
[PackageLocation local] -> ShowS
PackageLocation local -> String
(Int -> PackageLocation local -> ShowS)
-> (PackageLocation local -> String)
-> ([PackageLocation local] -> ShowS)
-> Show (PackageLocation local)
forall local. Show local => Int -> PackageLocation local -> ShowS
forall local. Show local => [PackageLocation local] -> ShowS
forall local. Show local => PackageLocation local -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall local. Show local => Int -> PackageLocation local -> ShowS
showsPrec :: Int -> PackageLocation local -> ShowS
$cshow :: forall local. Show local => PackageLocation local -> String
show :: PackageLocation local -> String
$cshowList :: forall local. Show local => [PackageLocation local] -> ShowS
showList :: [PackageLocation local] -> ShowS
Show, (forall a b. (a -> b) -> PackageLocation a -> PackageLocation b)
-> (forall a b. a -> PackageLocation b -> PackageLocation a)
-> Functor PackageLocation
forall a b. a -> PackageLocation b -> PackageLocation a
forall a b. (a -> b) -> PackageLocation a -> PackageLocation 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) -> PackageLocation a -> PackageLocation b
fmap :: forall a b. (a -> b) -> PackageLocation a -> PackageLocation b
$c<$ :: forall a b. a -> PackageLocation b -> PackageLocation a
<$ :: forall a b. a -> PackageLocation b -> PackageLocation a
Functor, PackageLocation local -> PackageLocation local -> Bool
(PackageLocation local -> PackageLocation local -> Bool)
-> (PackageLocation local -> PackageLocation local -> Bool)
-> Eq (PackageLocation local)
forall local.
Eq local =>
PackageLocation local -> PackageLocation local -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall local.
Eq local =>
PackageLocation local -> PackageLocation local -> Bool
== :: PackageLocation local -> PackageLocation local -> Bool
$c/= :: forall local.
Eq local =>
PackageLocation local -> PackageLocation local -> Bool
/= :: PackageLocation local -> PackageLocation local -> Bool
Eq, Eq (PackageLocation local)
Eq (PackageLocation local) =>
(PackageLocation local -> PackageLocation local -> Ordering)
-> (PackageLocation local -> PackageLocation local -> Bool)
-> (PackageLocation local -> PackageLocation local -> Bool)
-> (PackageLocation local -> PackageLocation local -> Bool)
-> (PackageLocation local -> PackageLocation local -> Bool)
-> (PackageLocation local
    -> PackageLocation local -> PackageLocation local)
-> (PackageLocation local
    -> PackageLocation local -> PackageLocation local)
-> Ord (PackageLocation local)
PackageLocation local -> PackageLocation local -> Bool
PackageLocation local -> PackageLocation local -> Ordering
PackageLocation local
-> PackageLocation local -> PackageLocation local
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 local. Ord local => Eq (PackageLocation local)
forall local.
Ord local =>
PackageLocation local -> PackageLocation local -> Bool
forall local.
Ord local =>
PackageLocation local -> PackageLocation local -> Ordering
forall local.
Ord local =>
PackageLocation local
-> PackageLocation local -> PackageLocation local
$ccompare :: forall local.
Ord local =>
PackageLocation local -> PackageLocation local -> Ordering
compare :: PackageLocation local -> PackageLocation local -> Ordering
$c< :: forall local.
Ord local =>
PackageLocation local -> PackageLocation local -> Bool
< :: PackageLocation local -> PackageLocation local -> Bool
$c<= :: forall local.
Ord local =>
PackageLocation local -> PackageLocation local -> Bool
<= :: PackageLocation local -> PackageLocation local -> Bool
$c> :: forall local.
Ord local =>
PackageLocation local -> PackageLocation local -> Bool
> :: PackageLocation local -> PackageLocation local -> Bool
$c>= :: forall local.
Ord local =>
PackageLocation local -> PackageLocation local -> Bool
>= :: PackageLocation local -> PackageLocation local -> Bool
$cmax :: forall local.
Ord local =>
PackageLocation local
-> PackageLocation local -> PackageLocation local
max :: PackageLocation local
-> PackageLocation local -> PackageLocation local
$cmin :: forall local.
Ord local =>
PackageLocation local
-> PackageLocation local -> PackageLocation local
min :: PackageLocation local
-> PackageLocation local -> PackageLocation local
Ord, (forall x. PackageLocation local -> Rep (PackageLocation local) x)
-> (forall x.
    Rep (PackageLocation local) x -> PackageLocation local)
-> Generic (PackageLocation local)
forall x. Rep (PackageLocation local) x -> PackageLocation local
forall x. PackageLocation local -> Rep (PackageLocation local) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall local x.
Rep (PackageLocation local) x -> PackageLocation local
forall local x.
PackageLocation local -> Rep (PackageLocation local) x
$cfrom :: forall local x.
PackageLocation local -> Rep (PackageLocation local) x
from :: forall x. PackageLocation local -> Rep (PackageLocation local) x
$cto :: forall local x.
Rep (PackageLocation local) x -> PackageLocation local
to :: forall x. Rep (PackageLocation local) x -> PackageLocation local
Generic, Typeable)

instance Binary local => Binary (PackageLocation local)
instance Structured local => Structured (PackageLocation local)

-- | Convenience alias for 'SourcePackage UnresolvedPkgLoc'.
type UnresolvedSourcePackage = SourcePackage UnresolvedPkgLoc