{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PartialTypeSignatures #-}
module Data.Registry.Options.Main where
import Data.Registry
import Data.Registry.Options.Parser
import Data.Registry.Options.Sources
import Protolude
run :: forall s a m. (KnownSymbol s, Typeable a, MonadIO m) => Registry _ _ -> m (Either Text a)
run :: Registry w w -> m (Either Text a)
run = forall (s :: Symbol) a (m :: * -> *) {ins :: [*]} {out :: [*]}
{ins :: [*]} {out :: [*]}.
(KnownSymbol s, Typeable a, MonadIO m) =>
(Registry
'[IO Priorities, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO OptionNames, IO EnvironmentNames, IO YamlNames, IO OptionNames,
IO (Maybe YamlByteString), IO Arguments, IO (Maybe YamlPath)]
'[IO OptionNames, IO Lexemes, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO Priorities, IO Arguments, IO EnvironmentNames, IO YamlNames,
IO (Maybe YamlByteString), IO OptionNames, IO (Maybe YamlPath)]
-> Registry ins out)
-> Registry ins out -> m (Either Text a)
runWith @s @a @m (forall a b. a -> b -> a
const Registry
'[IO Priorities, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO OptionNames, IO EnvironmentNames, IO YamlNames, IO OptionNames,
IO (Maybe YamlByteString), IO Arguments, IO (Maybe YamlPath)]
'[IO Lexemes, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO Priorities, IO Arguments, IO EnvironmentNames, IO YamlNames,
IO (Maybe YamlByteString), IO OptionNames, IO (Maybe YamlPath)]
sources)
runWith :: forall s a m. (KnownSymbol s, Typeable a, MonadIO m) => (Registry _ _ -> Registry _ _) -> Registry _ _ -> m (Either Text a)
runWith :: (Registry
'[IO Priorities, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO OptionNames, IO EnvironmentNames, IO YamlNames, IO OptionNames,
IO (Maybe YamlByteString), IO Arguments, IO (Maybe YamlPath)]
'[IO OptionNames, IO Lexemes, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO Priorities, IO Arguments, IO EnvironmentNames, IO YamlNames,
IO (Maybe YamlByteString), IO OptionNames, IO (Maybe YamlPath)]
-> Registry ins out)
-> Registry ins out -> m (Either Text a)
runWith Registry
'[IO Priorities, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO OptionNames, IO EnvironmentNames, IO YamlNames, IO OptionNames,
IO (Maybe YamlByteString), IO Arguments, IO (Maybe YamlPath)]
'[IO OptionNames, IO Lexemes, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO Priorities, IO Arguments, IO EnvironmentNames, IO YamlNames,
IO (Maybe YamlByteString), IO OptionNames, IO (Maybe YamlPath)]
-> Registry ins out
sourcesModifications Registry ins out
parserRegistry = do
let parser :: Parser s a
parser = forall a (ins :: [*]) (out :: [*]).
Typeable a =>
Registry ins out -> a
make @(Parser s a) Registry ins out
parserRegistry
let os :: [Text]
os = forall (s :: Symbol) a. Parser s a -> [Text]
getOptionNames Parser s a
parser
Lexemes
lexemes <- forall (m :: * -> *) {ins :: [*]} {out :: [*]}.
MonadIO m =>
(Registry
'[IO Priorities, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO OptionNames, IO EnvironmentNames, IO YamlNames, IO OptionNames,
IO (Maybe YamlByteString), IO Arguments, IO (Maybe YamlPath)]
'[IO Lexemes, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO Priorities, IO Arguments, IO EnvironmentNames, IO YamlNames,
IO (Maybe YamlByteString), IO OptionNames, IO (Maybe YamlPath)]
-> Registry ins out)
-> m Lexemes
getLexemesWith (Registry
'[IO Priorities, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO OptionNames, IO EnvironmentNames, IO YamlNames, IO OptionNames,
IO (Maybe YamlByteString), IO Arguments, IO (Maybe YamlPath)]
'[IO OptionNames, IO Lexemes, IO (Tag "environment" Lexemes),
IO (Tag "yaml" Lexemes), IO (Tag "commandline" Lexemes),
IO Priorities, IO Arguments, IO EnvironmentNames, IO YamlNames,
IO (Maybe YamlByteString), IO OptionNames, IO (Maybe YamlPath)]
-> Registry ins out
sourcesModifications forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall {w :: [*]} {out :: [*]}.
[Text] -> Registry w out -> Registry w (IO OptionNames : out)
setOptionNames [Text]
os)
forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ forall a b. (a, b) -> a
fst forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (s :: Symbol) a.
Parser s a -> Lexemes -> Either Text (a, Lexemes)
parseLexed Parser s a
parser Lexemes
lexemes