    {-# LANGUAGE CPP #-}
    {-# LANGUAGE OverloadedStrings #-}
    {-# LANGUAGE LambdaCase #-}
    module Hpack.Syntax.DependencyVersion (
      githubBaseUrl
    , GitRef
    , GitUrl

    , VersionConstraint(..)
    , versionConstraint
    , anyVersion
    , versionRange

    , DependencyVersion(..)
    , withDependencyVersion
    , dependencyVersion

    , SourceDependency(..)
    , objectDependency

    , versionConstraintFromCabal

    , scientificToVersion
    , cabalParse
    ) where

    import           Control.Applicative
    import qualified Control.Monad.Fail as Fail
    import           Data.Maybe
    import           Data.Scientific
    import           Data.Text (Text)
    import qualified Data.Text as T
    import qualified Data.HashMap.Strict as HashMap
    import           Text.PrettyPrint (renderStyle, Style(..), Mode(..))

    import           Distribution.Version (VersionRangeF(..))
    import qualified Distribution.Version as D

    import qualified Distribution.Parsec as D
    import qualified Distribution.Pretty as D

    import           Data.Aeson.Config.FromValue

    githubBaseUrl :: String
    githubBaseUrl :: String
    githubBaseUrl = "https://github.com/"

    type GitUrl = String
    type GitRef = String

    data VersionConstraint = AnyVersion | VersionRange String
      deriving (VersionConstraint -> VersionConstraint -> Bool
    (VersionConstraint -> VersionConstraint -> Bool)
    -> (VersionConstraint -> VersionConstraint -> Bool)
    -> Eq VersionConstraint
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: VersionConstraint -> VersionConstraint -> Bool
    $c/= :: VersionConstraint -> VersionConstraint -> Bool
    == :: VersionConstraint -> VersionConstraint -> Bool
    $c== :: VersionConstraint -> VersionConstraint -> Bool
    Eq, Int -> VersionConstraint -> ShowS
    [VersionConstraint] -> ShowS
    VersionConstraint -> String
    (Int -> VersionConstraint -> ShowS)
    -> (VersionConstraint -> String)
    -> ([VersionConstraint] -> ShowS)
    -> Show VersionConstraint
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [VersionConstraint] -> ShowS
    $cshowList :: [VersionConstraint] -> ShowS
    show :: VersionConstraint -> String
    $cshow :: VersionConstraint -> String
    showsPrec :: Int -> VersionConstraint -> ShowS
    $cshowsPrec :: Int -> VersionConstraint -> ShowS
    Show)

    instance FromValue VersionConstraint where
      fromValue :: Value -> Parser VersionConstraint
    fromValue = Value -> Parser VersionConstraint
    versionConstraint

    versionConstraint :: Value -> Parser VersionConstraint
    versionConstraint :: Value -> Parser VersionConstraint
    versionConstraint v :: Value
    v = case Value
    v of
      Null -> VersionConstraint -> Parser VersionConstraint
    forall (m :: * -> *) a. Monad m => a -> m a
    return VersionConstraint
    AnyVersion
      Number n :: Scientific
    n -> VersionConstraint -> Parser VersionConstraint
    forall (m :: * -> *) a. Monad m => a -> m a
    return (Scientific -> VersionConstraint
    numericVersionConstraint Scientific
    n)
      String s :: Text
    s -> Text -> Parser VersionConstraint
    stringVersionConstraint Text
    s
      _ -> String -> Value -> Parser VersionConstraint
    forall a. String -> Value -> Parser a
    typeMismatch "Null, Number, or String" Value
    v

    anyVersion :: DependencyVersion
    anyVersion :: DependencyVersion
    anyVersion = Maybe SourceDependency -> VersionConstraint -> DependencyVersion
    DependencyVersion Maybe SourceDependency
    forall a. Maybe a
    Nothing VersionConstraint
    AnyVersion

    versionRange :: String -> DependencyVersion
    versionRange :: String -> DependencyVersion
    versionRange = Maybe SourceDependency -> VersionConstraint -> DependencyVersion
    DependencyVersion Maybe SourceDependency
    forall a. Maybe a
    Nothing (VersionConstraint -> DependencyVersion)
    -> (String -> VersionConstraint) -> String -> DependencyVersion
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> VersionConstraint
    VersionRange

    data DependencyVersion = DependencyVersion (Maybe SourceDependency) VersionConstraint
      deriving (DependencyVersion -> DependencyVersion -> Bool
    (DependencyVersion -> DependencyVersion -> Bool)
    -> (DependencyVersion -> DependencyVersion -> Bool)
    -> Eq DependencyVersion
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: DependencyVersion -> DependencyVersion -> Bool
    $c/= :: DependencyVersion -> DependencyVersion -> Bool
    == :: DependencyVersion -> DependencyVersion -> Bool
    $c== :: DependencyVersion -> DependencyVersion -> Bool
    Eq, Int -> DependencyVersion -> ShowS
    [DependencyVersion] -> ShowS
    DependencyVersion -> String
    (Int -> DependencyVersion -> ShowS)
    -> (DependencyVersion -> String)
    -> ([DependencyVersion] -> ShowS)
    -> Show DependencyVersion
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [DependencyVersion] -> ShowS
    $cshowList :: [DependencyVersion] -> ShowS
    show :: DependencyVersion -> String
    $cshow :: DependencyVersion -> String
    showsPrec :: Int -> DependencyVersion -> ShowS
    $cshowsPrec :: Int -> DependencyVersion -> ShowS
    Show)

    withDependencyVersion
      :: (DependencyVersion -> a)
      -> (Object -> DependencyVersion -> Parser a)
      -> Value
      -> Parser a
    withDependencyVersion :: (DependencyVersion -> a)
    -> (Object -> DependencyVersion -> Parser a) -> Value -> Parser a
    withDependencyVersion k :: DependencyVersion -> a
    k obj :: Object -> DependencyVersion -> Parser a
    obj v :: Value
    v = case Value
    v of
      Null -> a -> Parser a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (a -> Parser a) -> a -> Parser a
    forall a b. (a -> b) -> a -> b
    $ DependencyVersion -> a
    k DependencyVersion
    anyVersion
      Object o :: Object
    o -> Object -> Parser DependencyVersion
    objectDependency Object
    o Parser DependencyVersion
    -> (DependencyVersion -> Parser a) -> Parser a
    forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
    >>= Object -> DependencyVersion -> Parser a
    obj Object
    o
      Number n :: Scientific
    n -> a -> Parser a
    forall (m :: * -> *) a. Monad m => a -> m a
    return (a -> Parser a) -> a -> Parser a
    forall a b. (a -> b) -> a -> b
    $ DependencyVersion -> a
    k (Maybe SourceDependency -> VersionConstraint -> DependencyVersion
    DependencyVersion Maybe SourceDependency
    forall a. Maybe a
    Nothing (VersionConstraint -> DependencyVersion)
    -> VersionConstraint -> DependencyVersion
    forall a b. (a -> b) -> a -> b
    $ Scientific -> VersionConstraint
    numericVersionConstraint Scientific
    n)
      String s :: Text
    s -> DependencyVersion -> a
    k (DependencyVersion -> a)
    -> (VersionConstraint -> DependencyVersion)
    -> VersionConstraint
    -> a
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Maybe SourceDependency -> VersionConstraint -> DependencyVersion
    DependencyVersion Maybe SourceDependency
    forall a. Maybe a
    Nothing (VersionConstraint -> a) -> Parser VersionConstraint -> Parser a
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Text -> Parser VersionConstraint
    stringVersionConstraint Text
    s
      _ -> String -> Value -> Parser a
    forall a. String -> Value -> Parser a
    typeMismatch "Null, Object, Number, or String" Value
    v

    dependencyVersion :: Value -> Parser DependencyVersion
    dependencyVersion :: Value -> Parser DependencyVersion
    dependencyVersion = (DependencyVersion -> DependencyVersion)
    -> (Object -> DependencyVersion -> Parser DependencyVersion)
    -> Value
    -> Parser DependencyVersion
    forall a.
    (DependencyVersion -> a)
    -> (Object -> DependencyVersion -> Parser a) -> Value -> Parser a
    withDependencyVersion DependencyVersion -> DependencyVersion
    forall a. a -> a
    id ((DependencyVersion -> Parser DependencyVersion)
    -> Object -> DependencyVersion -> Parser DependencyVersion
    forall a b. a -> b -> a
    const DependencyVersion -> Parser DependencyVersion
    forall (m :: * -> *) a. Monad m => a -> m a
    return)

    data SourceDependency = GitRef GitUrl GitRef (Maybe FilePath) | Local FilePath
      deriving (SourceDependency -> SourceDependency -> Bool
    (SourceDependency -> SourceDependency -> Bool)
    -> (SourceDependency -> SourceDependency -> Bool)
    -> Eq SourceDependency
    forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
    /= :: SourceDependency -> SourceDependency -> Bool
    $c/= :: SourceDependency -> SourceDependency -> Bool
    == :: SourceDependency -> SourceDependency -> Bool
    $c== :: SourceDependency -> SourceDependency -> Bool
    Eq, Int -> SourceDependency -> ShowS
    [SourceDependency] -> ShowS
    SourceDependency -> String
    (Int -> SourceDependency -> ShowS)
    -> (SourceDependency -> String)
    -> ([SourceDependency] -> ShowS)
    -> Show SourceDependency
    forall a.
    (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
    showList :: [SourceDependency] -> ShowS
    $cshowList :: [SourceDependency] -> ShowS
    show :: SourceDependency -> String
    $cshow :: SourceDependency -> String
    showsPrec :: Int -> SourceDependency -> ShowS
    $cshowsPrec :: Int -> SourceDependency -> ShowS
    Show)

    objectDependency :: Object -> Parser DependencyVersion
    objectDependency :: Object -> Parser DependencyVersion
    objectDependency o :: Object
    o = let
        version :: Parser VersionConstraint
        version :: Parser VersionConstraint
    version = VersionConstraint -> Maybe VersionConstraint -> VersionConstraint
    forall a. a -> Maybe a -> a
    fromMaybe VersionConstraint
    AnyVersion (Maybe VersionConstraint -> VersionConstraint)
    -> Parser (Maybe VersionConstraint) -> Parser VersionConstraint
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Object
    o Object -> Text -> Parser (Maybe VersionConstraint)
    forall a. FromValue a => Object -> Text -> Parser (Maybe a)
    .:? "version")

        local :: Parser SourceDependency
        local :: Parser SourceDependency
    local = String -> SourceDependency
    Local (String -> SourceDependency)
    -> Parser String -> Parser SourceDependency
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Object
    o Object -> Text -> Parser String
    forall a. FromValue a => Object -> Text -> Parser a
    .: "path"

        git :: Parser SourceDependency
        git :: Parser SourceDependency
    git = String -> String -> Maybe String -> SourceDependency
    GitRef (String -> String -> Maybe String -> SourceDependency)
    -> Parser String
    -> Parser (String -> Maybe String -> SourceDependency)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser String
    url Parser (String -> Maybe String -> SourceDependency)
    -> Parser String -> Parser (Maybe String -> SourceDependency)
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser String
    ref Parser (Maybe String -> SourceDependency)
    -> Parser (Maybe String) -> Parser SourceDependency
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser (Maybe String)
    subdir

        url :: Parser String
        url :: Parser String
    url =
              ((String
    githubBaseUrl String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++) ShowS -> Parser String -> Parser String
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Object
    o Object -> Text -> Parser String
    forall a. FromValue a => Object -> Text -> Parser a
    .: "github")
          Parser String -> Parser String -> Parser String
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> (Object
    o Object -> Text -> Parser String
    forall a. FromValue a => Object -> Text -> Parser a
    .: "git")
          Parser String -> Parser String -> Parser String
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> String -> Parser String
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail "neither key \"git\" nor key \"github\" present"

        ref :: Parser String
        ref :: Parser String
    ref = Object
    o Object -> Text -> Parser String
    forall a. FromValue a => Object -> Text -> Parser a
    .: "ref"

        subdir :: Parser (Maybe FilePath)
        subdir :: Parser (Maybe String)
    subdir = Object
    o Object -> Text -> Parser (Maybe String)
    forall a. FromValue a => Object -> Text -> Parser (Maybe a)
    .:? "subdir"

        source :: Parser (Maybe SourceDependency)
        source :: Parser (Maybe SourceDependency)
    source
          | (Text -> Bool) -> [Text] -> Bool
    forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
    any (Text -> Object -> Bool
    forall k a. (Eq k, Hashable k) => k -> HashMap k a -> Bool
    `HashMap.member` Object
    o) ["path", "git", "github", "ref", "subdir"] = SourceDependency -> Maybe SourceDependency
    forall a. a -> Maybe a
    Just (SourceDependency -> Maybe SourceDependency)
    -> Parser SourceDependency -> Parser (Maybe SourceDependency)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> (Parser SourceDependency
    local Parser SourceDependency
    -> Parser SourceDependency -> Parser SourceDependency
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> Parser SourceDependency
    git)
          | Bool
    otherwise = Maybe SourceDependency -> Parser (Maybe SourceDependency)
    forall (m :: * -> *) a. Monad m => a -> m a
    return Maybe SourceDependency
    forall a. Maybe a
    Nothing

        in Maybe SourceDependency -> VersionConstraint -> DependencyVersion
    DependencyVersion (Maybe SourceDependency -> VersionConstraint -> DependencyVersion)
    -> Parser (Maybe SourceDependency)
    -> Parser (VersionConstraint -> DependencyVersion)
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    <$> Parser (Maybe SourceDependency)
    source Parser (VersionConstraint -> DependencyVersion)
    -> Parser VersionConstraint -> Parser DependencyVersion
    forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
    <*> Parser VersionConstraint
    version

    numericVersionConstraint :: Scientific -> VersionConstraint
    numericVersionConstraint :: Scientific -> VersionConstraint
    numericVersionConstraint n :: Scientific
    n = String -> VersionConstraint
    VersionRange ("==" String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    version)
      where
        version :: String
    version = Scientific -> String
    scientificToVersion Scientific
    n

    stringVersionConstraint :: Text -> Parser VersionConstraint
    stringVersionConstraint :: Text -> Parser VersionConstraint
    stringVersionConstraint s :: Text
    s = String -> Parser VersionConstraint
    forall (m :: * -> *). MonadFail m => String -> m VersionConstraint
    parseVersionRange ("== " String -> ShowS
    forall a. [a] -> [a] -> [a]
    ++ String
    input) Parser VersionConstraint
    -> Parser VersionConstraint -> Parser VersionConstraint
    forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
    <|> String -> Parser VersionConstraint
    forall (m :: * -> *). MonadFail m => String -> m VersionConstraint
    parseVersionRange String
    input
      where
        input :: String
    input = Text -> String
    T.unpack Text
    s

    scientificToVersion :: Scientific -> String
    scientificToVersion :: Scientific -> String
    scientificToVersion n :: Scientific
    n = String
    version
      where
        version :: String
    version = FPFormat -> Maybe Int -> Scientific -> String
    formatScientific FPFormat
    Fixed (Int -> Maybe Int
    forall a. a -> Maybe a
    Just Int
    decimalPlaces) Scientific
    n
        decimalPlaces :: Int
    decimalPlaces
          | Int
    e Int -> Int -> Bool
    forall a. Ord a => a -> a -> Bool
    < 0 = Int -> Int
    forall a. Num a => a -> a
    abs Int
    e
          | Bool
    otherwise = 0
        e :: Int
    e = Scientific -> Int
    base10Exponent Scientific
    n

    parseVersionRange :: Fail.MonadFail m => String -> m VersionConstraint
    parseVersionRange :: String -> m VersionConstraint
    parseVersionRange = (VersionRange -> VersionConstraint)
    -> m VersionRange -> m VersionConstraint
    forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
    fmap VersionRange -> VersionConstraint
    versionConstraintFromCabal (m VersionRange -> m VersionConstraint)
    -> (String -> m VersionRange) -> String -> m VersionConstraint
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . String -> m VersionRange
    forall (m :: * -> *). MonadFail m => String -> m VersionRange
    parseCabalVersionRange

    parseCabalVersionRange :: Fail.MonadFail m => String -> m D.VersionRange
    parseCabalVersionRange :: String -> m VersionRange
    parseCabalVersionRange = String -> String -> m VersionRange
    forall (m :: * -> *) a.
    (MonadFail m, Parsec a) =>
    String -> String -> m a
    cabalParse "constraint"

    cabalParse :: (Fail.MonadFail m, D.Parsec a) => String -> String -> m a
    cabalParse :: String -> String -> m a
    cabalParse subject :: String
    subject s :: String
    s = case String -> Either String a
    forall a. Parsec a => String -> Either String a
    D.eitherParsec String
    s of
      Right d :: a
    d -> a -> m a
    forall (m :: * -> *) a. Monad m => a -> m a
    return a
    d
      Left _ ->String -> m a
    forall (m :: * -> *) a. MonadFail m => String -> m a
    fail (String -> m a) -> String -> m a
    forall a b. (a -> b) -> a -> b
    $ [String] -> String
    unwords ["invalid",  String
    subject, ShowS
    forall a. Show a => a -> String
    show String
    s]

    versionConstraintFromCabal :: D.VersionRange -> VersionConstraint
    versionConstraintFromCabal :: VersionRange -> VersionConstraint
    versionConstraintFromCabal range :: VersionRange
    range
      | VersionRange -> Bool
    D.isAnyVersion VersionRange
    range = VersionConstraint
    AnyVersion
      | Bool
    otherwise = String -> VersionConstraint
    VersionRange (String -> VersionConstraint)
    -> (VersionRange -> String) -> VersionRange -> VersionConstraint
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . Style -> Doc -> String
    renderStyle Style
    style (Doc -> String) -> (VersionRange -> Doc) -> VersionRange -> String
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    .
          VersionRange -> Doc
    forall a. Pretty a => a -> Doc
    D.pretty
          (VersionRange -> VersionConstraint)
    -> VersionRange -> VersionConstraint
    forall a b. (a -> b) -> a -> b
    $ VersionRange -> VersionRange
    toPreCabal2VersionRange VersionRange
    range
      where
        style :: Style
    style = Mode -> Int -> Float -> Style
    Style Mode
    OneLineMode 0 0

        toPreCabal2VersionRange :: D.VersionRange -> D.VersionRange
        toPreCabal2VersionRange :: VersionRange -> VersionRange
    toPreCabal2VersionRange = VersionRangeF VersionRange -> VersionRange
    D.embedVersionRange (VersionRangeF VersionRange -> VersionRange)
    -> (VersionRange -> VersionRangeF VersionRange)
    -> VersionRange
    -> VersionRange
    forall b c a. (b -> c) -> (a -> b) -> a -> c
    . (VersionRangeF (VersionRangeF VersionRange)
     -> VersionRangeF VersionRange)
    -> VersionRange -> VersionRangeF VersionRange
    forall a. (VersionRangeF a -> a) -> VersionRange -> a
    D.cataVersionRange VersionRangeF (VersionRangeF VersionRange)
    -> VersionRangeF VersionRange
    f
          where
            f :: VersionRangeF (VersionRangeF D.VersionRange) -> VersionRangeF D.VersionRange
            f :: VersionRangeF (VersionRangeF VersionRange)
    -> VersionRangeF VersionRange
    f = \ case
              MajorBoundVersionF v :: Version
    v -> VersionRange -> VersionRange -> VersionRangeF VersionRange
    forall a. a -> a -> VersionRangeF a
    IntersectVersionRangesF (VersionRangeF VersionRange -> VersionRange
    D.embedVersionRange VersionRangeF VersionRange
    forall a. VersionRangeF a
    lower) (VersionRangeF VersionRange -> VersionRange
    D.embedVersionRange VersionRangeF VersionRange
    forall a. VersionRangeF a
    upper)
                where
                  lower :: VersionRangeF a
    lower = Version -> VersionRangeF a
    forall a. Version -> VersionRangeF a
    OrLaterVersionF Version
    v
                  upper :: VersionRangeF a
    upper = Version -> VersionRangeF a
    forall a. Version -> VersionRangeF a
    EarlierVersionF (Version -> Version
    D.majorUpperBound Version
    v)

              AnyVersionF -> VersionRangeF VersionRange
    forall a. VersionRangeF a
    AnyVersionF
              ThisVersionF v :: Version
    v -> Version -> VersionRangeF VersionRange
    forall a. Version -> VersionRangeF a
    ThisVersionF Version
    v
              LaterVersionF v :: Version
    v -> Version -> VersionRangeF VersionRange
    forall a. Version -> VersionRangeF a
    LaterVersionF Version
    v
              OrLaterVersionF v :: Version
    v -> Version -> VersionRangeF VersionRange
    forall a. Version -> VersionRangeF a
    OrLaterVersionF Version
    v
              EarlierVersionF v :: Version
    v -> Version -> VersionRangeF VersionRange
    forall a. Version -> VersionRangeF a
    EarlierVersionF Version
    v
              OrEarlierVersionF v :: Version
    v -> Version -> VersionRangeF VersionRange
    forall a. Version -> VersionRangeF a
    OrEarlierVersionF Version
    v
              WildcardVersionF v :: Version
    v -> Version -> VersionRangeF VersionRange
    forall a. Version -> VersionRangeF a
    WildcardVersionF Version
    v
              UnionVersionRangesF a :: VersionRangeF VersionRange
    a b :: VersionRangeF VersionRange
    b -> VersionRange -> VersionRange -> VersionRangeF VersionRange
    forall a. a -> a -> VersionRangeF a
    UnionVersionRangesF (VersionRangeF VersionRange -> VersionRange
    D.embedVersionRange VersionRangeF VersionRange
    a) (VersionRangeF VersionRange -> VersionRange
    D.embedVersionRange VersionRangeF VersionRange
    b)
              IntersectVersionRangesF a :: VersionRangeF VersionRange
    a b :: VersionRangeF VersionRange
    b -> VersionRange -> VersionRange -> VersionRangeF VersionRange
    forall a. a -> a -> VersionRangeF a
    IntersectVersionRangesF (VersionRangeF VersionRange -> VersionRange
    D.embedVersionRange VersionRangeF VersionRange
    a) (VersionRangeF VersionRange -> VersionRange
    D.embedVersionRange VersionRangeF VersionRange
    b)
              VersionRangeParensF a :: VersionRangeF VersionRange
    a -> VersionRange -> VersionRangeF VersionRange
    forall a. a -> VersionRangeF a
    VersionRangeParensF (VersionRangeF VersionRange -> VersionRange
    D.embedVersionRange VersionRangeF VersionRange
    a)