{-# LANGUAGE DeriveGeneric #-}
module Distribution.Client.Types.InstallMethod where

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

import qualified Distribution.Compat.CharParsing as P
import qualified Text.PrettyPrint                as PP

data InstallMethod
    = InstallMethodCopy
    | InstallMethodSymlink
  deriving (InstallMethod -> InstallMethod -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstallMethod -> InstallMethod -> Bool
$c/= :: InstallMethod -> InstallMethod -> Bool
== :: InstallMethod -> InstallMethod -> Bool
$c== :: InstallMethod -> InstallMethod -> Bool
Eq, Int -> InstallMethod -> ShowS
[InstallMethod] -> ShowS
InstallMethod -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstallMethod] -> ShowS
$cshowList :: [InstallMethod] -> ShowS
show :: InstallMethod -> String
$cshow :: InstallMethod -> String
showsPrec :: Int -> InstallMethod -> ShowS
$cshowsPrec :: Int -> InstallMethod -> ShowS
Show, forall x. Rep InstallMethod x -> InstallMethod
forall x. InstallMethod -> Rep InstallMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstallMethod x -> InstallMethod
$cfrom :: forall x. InstallMethod -> Rep InstallMethod x
Generic, InstallMethod
forall a. a -> a -> Bounded a
maxBound :: InstallMethod
$cmaxBound :: InstallMethod
minBound :: InstallMethod
$cminBound :: InstallMethod
Bounded, Int -> InstallMethod
InstallMethod -> Int
InstallMethod -> [InstallMethod]
InstallMethod -> InstallMethod
InstallMethod -> InstallMethod -> [InstallMethod]
InstallMethod -> InstallMethod -> InstallMethod -> [InstallMethod]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: InstallMethod -> InstallMethod -> InstallMethod -> [InstallMethod]
$cenumFromThenTo :: InstallMethod -> InstallMethod -> InstallMethod -> [InstallMethod]
enumFromTo :: InstallMethod -> InstallMethod -> [InstallMethod]
$cenumFromTo :: InstallMethod -> InstallMethod -> [InstallMethod]
enumFromThen :: InstallMethod -> InstallMethod -> [InstallMethod]
$cenumFromThen :: InstallMethod -> InstallMethod -> [InstallMethod]
enumFrom :: InstallMethod -> [InstallMethod]
$cenumFrom :: InstallMethod -> [InstallMethod]
fromEnum :: InstallMethod -> Int
$cfromEnum :: InstallMethod -> Int
toEnum :: Int -> InstallMethod
$ctoEnum :: Int -> InstallMethod
pred :: InstallMethod -> InstallMethod
$cpred :: InstallMethod -> InstallMethod
succ :: InstallMethod -> InstallMethod
$csucc :: InstallMethod -> InstallMethod
Enum)

instance Binary InstallMethod
instance Structured InstallMethod

-- | Last
instance Semigroup InstallMethod where
    InstallMethod
_ <> :: InstallMethod -> InstallMethod -> InstallMethod
<> InstallMethod
x = InstallMethod
x

instance Parsec InstallMethod where
    parsec :: forall (m :: * -> *). CabalParsing m => m InstallMethod
parsec = do
        String
name <- forall (m :: * -> *). CharParsing m => (Char -> Bool) -> m String
P.munch1 Char -> Bool
isAlpha
        case String
name of
            String
"copy"    -> forall (f :: * -> *) a. Applicative f => a -> f a
pure InstallMethod
InstallMethodCopy
            String
"symlink" -> forall (f :: * -> *) a. Applicative f => a -> f a
pure InstallMethod
InstallMethodSymlink
            String
_         -> forall (m :: * -> *) a. Parsing m => String -> m a
P.unexpected forall a b. (a -> b) -> a -> b
$ String
"InstallMethod: " forall a. [a] -> [a] -> [a]
++ String
name

instance Pretty InstallMethod where
    pretty :: InstallMethod -> Doc
pretty InstallMethod
InstallMethodCopy    = String -> Doc
PP.text String
"copy"
    pretty InstallMethod
InstallMethodSymlink = String -> Doc
PP.text String
"symlink"