module Imp.Type.Context where import qualified Control.Monad as Monad import qualified Control.Monad.Catch as Exception import qualified Data.Map as Map import qualified Imp.Exception.ShowHelp as ShowHelp import qualified Imp.Exception.ShowVersion as ShowVersion import qualified Imp.Type.Alias as Alias import qualified Imp.Type.Config as Config import qualified Imp.Type.Source as Source import qualified Imp.Type.Target as Target newtype Context = Context { Context -> Map Target Source aliases :: Map.Map Target.Target Source.Source } deriving (Context -> Context -> Bool (Context -> Context -> Bool) -> (Context -> Context -> Bool) -> Eq Context forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: Context -> Context -> Bool == :: Context -> Context -> Bool $c/= :: Context -> Context -> Bool /= :: Context -> Context -> Bool Eq, Int -> Context -> ShowS [Context] -> ShowS Context -> String (Int -> Context -> ShowS) -> (Context -> String) -> ([Context] -> ShowS) -> Show Context forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> Context -> ShowS showsPrec :: Int -> Context -> ShowS $cshow :: Context -> String show :: Context -> String $cshowList :: [Context] -> ShowS showList :: [Context] -> ShowS Show) fromConfig :: (Exception.MonadThrow m) => Config.Config -> m Context fromConfig :: forall (m :: * -> *). MonadThrow m => Config -> m Context fromConfig Config config = do Bool -> m () -> m () forall (f :: * -> *). Applicative f => Bool -> f () -> f () Monad.when (Config -> Bool Config.help Config config) (m () -> m ()) -> m () -> m () forall a b. (a -> b) -> a -> b $ ShowHelp -> m () forall e a. (HasCallStack, Exception e) => e -> m a forall (m :: * -> *) e a. (MonadThrow m, HasCallStack, Exception e) => e -> m a Exception.throwM ShowHelp ShowHelp.new Bool -> m () -> m () forall (f :: * -> *). Applicative f => Bool -> f () -> f () Monad.when (Config -> Bool Config.version Config config) (m () -> m ()) -> m () -> m () forall a b. (a -> b) -> a -> b $ ShowVersion -> m () forall e a. (HasCallStack, Exception e) => e -> m a forall (m :: * -> *) e a. (MonadThrow m, HasCallStack, Exception e) => e -> m a Exception.throwM ShowVersion ShowVersion.new Context -> m Context forall a. a -> m a forall (f :: * -> *) a. Applicative f => a -> f a pure Context { aliases :: Map Target Source aliases = [Alias] -> Map Target Source Alias.toMap ([Alias] -> Map Target Source) -> [Alias] -> Map Target Source forall a b. (a -> b) -> a -> b $ Config -> [Alias] Config.aliases Config config }