{-# OPTIONS_GHC -Wall #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE LambdaCase #-} module Control.Process.CmdSpec( AsCmdSpec(..) , HasCmdSpec(..) ) where import Control.Category ( Category(id, (.)) ) import Control.Lens ( Traversable(traverse), prism', Field1(_1), Field2(_2), Lens', Prism', Traversal' ) import Data.Maybe ( Maybe(Nothing, Just) ) import Data.Functor ( Functor(fmap) ) import Data.String ( String ) import Data.Tuple ( uncurry ) import System.FilePath ( FilePath ) import System.Process ( CreateProcess(..), CmdSpec(..) ) class AsCmdSpec a where _CmdSpec :: Prism' a CmdSpec _ShellCommand :: Prism' a String _ShellCommand = forall a. AsCmdSpec a => Prism' a CmdSpec _CmdSpec forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall a. AsCmdSpec a => Prism' a String _ShellCommand _RawCommand :: Prism' a (FilePath, [String]) _RawCommand = forall a. AsCmdSpec a => Prism' a CmdSpec _CmdSpec forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall a. AsCmdSpec a => Prism' a (String, [String]) _RawCommand _RawCommandExe :: Traversal' a FilePath _RawCommandExe = forall a. AsCmdSpec a => Prism' a (String, [String]) _RawCommand forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall s t a b. Field1 s t a b => Lens s t a b _1 _RawCommandArgumentList :: Traversal' a [String] _RawCommandArgumentList = forall a. AsCmdSpec a => Prism' a (String, [String]) _RawCommand forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall s t a b. Field2 s t a b => Lens s t a b _2 _RawCommandArguments :: Traversal' a String _RawCommandArguments = forall a. AsCmdSpec a => Traversal' a [String] _RawCommandArgumentList forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse instance AsCmdSpec CmdSpec where _CmdSpec :: Prism' CmdSpec CmdSpec _CmdSpec = forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a id _ShellCommand :: Prism' CmdSpec String _ShellCommand = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b prism' String -> CmdSpec ShellCommand (\case ShellCommand String a -> forall a. a -> Maybe a Just String a CmdSpec _ -> forall a. Maybe a Nothing ) _RawCommand :: Prism' CmdSpec (String, [String]) _RawCommand = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b prism' (forall a b c. (a -> b -> c) -> (a, b) -> c uncurry String -> [String] -> CmdSpec RawCommand) (\case RawCommand String a [String] b -> forall a. a -> Maybe a Just (String a, [String] b) CmdSpec _ -> forall a. Maybe a Nothing ) class HasCmdSpec a where cmdSpec :: Lens' a CmdSpec shellCommand :: Traversal' a String shellCommand = forall a. HasCmdSpec a => Lens' a CmdSpec cmdSpec forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall a. AsCmdSpec a => Prism' a String _ShellCommand rawCommand :: Traversal' a (FilePath, [String]) rawCommand = forall a. HasCmdSpec a => Lens' a CmdSpec cmdSpec forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall a. AsCmdSpec a => Prism' a (String, [String]) _RawCommand rawCommandExe :: Traversal' a FilePath rawCommandExe = forall a. HasCmdSpec a => Traversal' a (String, [String]) rawCommand forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall s t a b. Field1 s t a b => Lens s t a b _1 rawCommandArgumentList :: Traversal' a [String] rawCommandArgumentList = forall a. HasCmdSpec a => Traversal' a (String, [String]) rawCommand forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall s t a b. Field2 s t a b => Lens s t a b _2 rawCommandArguments :: Traversal' a String rawCommandArguments = forall a. HasCmdSpec a => Traversal' a [String] rawCommandArgumentList forall {k} (cat :: k -> k -> *) (b :: k) (c :: k) (a :: k). Category cat => cat b c -> cat a b -> cat a c . forall (t :: * -> *) (f :: * -> *) a b. (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b) traverse instance HasCmdSpec CmdSpec where cmdSpec :: Lens' CmdSpec CmdSpec cmdSpec = forall {k} (cat :: k -> k -> *) (a :: k). Category cat => cat a a id instance HasCmdSpec CreateProcess where cmdSpec :: Lens' CreateProcess CmdSpec cmdSpec CmdSpec -> f CmdSpec f (CreateProcess CmdSpec csc Maybe String cw Maybe [(String, String)] en StdStream sti StdStream sto StdStream ste Bool clf Bool crg Bool dct Bool dcl Bool cnc Bool nss Maybe GroupID chg Maybe UserID chu Bool upj) = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b fmap (\CmdSpec csc' -> CmdSpec -> Maybe String -> Maybe [(String, String)] -> StdStream -> StdStream -> StdStream -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe GroupID -> Maybe UserID -> Bool -> CreateProcess CreateProcess CmdSpec csc' Maybe String cw Maybe [(String, String)] en StdStream sti StdStream sto StdStream ste Bool clf Bool crg Bool dct Bool dcl Bool cnc Bool nss Maybe GroupID chg Maybe UserID chu Bool upj) (CmdSpec -> f CmdSpec f CmdSpec csc)