module CabalGild.Unstable.Type.Output where

-- | Represents an output stream, which can either be standard output
-- (STDOUT) or a file.
data Output
  = Stdout
  | File FilePath
  deriving (Output -> Output -> Bool
(Output -> Output -> Bool)
-> (Output -> Output -> Bool) -> Eq Output
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Output -> Output -> Bool
== :: Output -> Output -> Bool
$c/= :: Output -> Output -> Bool
/= :: Output -> Output -> Bool
Eq, Eq Output
Eq Output =>
(Output -> Output -> Ordering)
-> (Output -> Output -> Bool)
-> (Output -> Output -> Bool)
-> (Output -> Output -> Bool)
-> (Output -> Output -> Bool)
-> (Output -> Output -> Output)
-> (Output -> Output -> Output)
-> Ord Output
Output -> Output -> Bool
Output -> Output -> Ordering
Output -> Output -> Output
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
$ccompare :: Output -> Output -> Ordering
compare :: Output -> Output -> Ordering
$c< :: Output -> Output -> Bool
< :: Output -> Output -> Bool
$c<= :: Output -> Output -> Bool
<= :: Output -> Output -> Bool
$c> :: Output -> Output -> Bool
> :: Output -> Output -> Bool
$c>= :: Output -> Output -> Bool
>= :: Output -> Output -> Bool
$cmax :: Output -> Output -> Output
max :: Output -> Output -> Output
$cmin :: Output -> Output -> Output
min :: Output -> Output -> Output
Ord, Int -> Output -> ShowS
[Output] -> ShowS
Output -> FilePath
(Int -> Output -> ShowS)
-> (Output -> FilePath) -> ([Output] -> ShowS) -> Show Output
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Output -> ShowS
showsPrec :: Int -> Output -> ShowS
$cshow :: Output -> FilePath
show :: Output -> FilePath
$cshowList :: [Output] -> ShowS
showList :: [Output] -> ShowS
Show)

-- | Converts a string into an output. The string @"-"@ will be converted into
-- 'Stdout', and any other string will be converted into 'File'.
fromString :: String -> Output
fromString :: FilePath -> Output
fromString FilePath
s = case FilePath
s of
  FilePath
"-" -> Output
Stdout
  FilePath
_ -> FilePath -> Output
File FilePath
s