{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.PackageVersionConstraint
( PackageVersionConstraint(..)
) where
import Distribution.Compat.Prelude
import Prelude ()
import Distribution.Parsec
import Distribution.Pretty
import Distribution.Types.PackageName
import Distribution.Types.VersionRange
import qualified Distribution.Compat.CharParsing as P
import Text.PrettyPrint ((<+>))
data PackageVersionConstraint = PackageVersionConstraint PackageName VersionRange
deriving (Generic, Read, Show, Eq, Typeable, Data)
instance Binary PackageVersionConstraint
instance NFData PackageVersionConstraint where rnf = genericRnf
instance Pretty PackageVersionConstraint where
pretty (PackageVersionConstraint name ver) = pretty name <+> pretty ver
instance Parsec PackageVersionConstraint where
parsec = do
name <- parsec
P.spaces
ver <- parsec <|> return anyVersion
P.spaces
return (PackageVersionConstraint name ver)