{-# OPTIONS_GHC -Wno-redundant-constraints #-}
module Effectful.Optparse.Static
(
Optparse,
execParser,
customExecParser,
handleParseResult,
runOptparse,
Utils.OsPath,
Utils.osPath,
Utils.validOsPath,
)
where
import Effectful
( Dispatch (Static),
DispatchOf,
Eff,
Effect,
IOE,
type (:>),
)
import Effectful.Dispatch.Static
( HasCallStack,
SideEffects (WithSideEffects),
StaticRep,
evalStaticRep,
unsafeEff_,
)
import Effectful.Optparse.Utils qualified as Utils
import Options.Applicative (ParserInfo, ParserPrefs, ParserResult)
import Options.Applicative qualified as OA
data Optparse :: Effect
type instance DispatchOf Optparse = Static WithSideEffects
data instance StaticRep Optparse = MkOptparse
runOptparse :: (HasCallStack, IOE :> es) => Eff (Optparse : es) a -> Eff es a
runOptparse :: forall (es :: [Effect]) a.
(HasCallStack, IOE :> es) =>
Eff (Optparse : es) a -> Eff es a
runOptparse = StaticRep Optparse -> Eff (Optparse : es) a -> Eff es a
forall (e :: Effect) (sideEffects :: SideEffects) (es :: [Effect])
a.
(HasCallStack, DispatchOf e ~ 'Static sideEffects,
MaybeIOE sideEffects es) =>
StaticRep e -> Eff (e : es) a -> Eff es a
evalStaticRep StaticRep Optparse
MkOptparse
execParser :: (HasCallStack, Optparse :> es) => ParserInfo a -> Eff es a
execParser :: forall (es :: [Effect]) a.
(HasCallStack, Optparse :> es) =>
ParserInfo a -> Eff es a
execParser = IO a -> Eff es a
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO a -> Eff es a)
-> (ParserInfo a -> IO a) -> ParserInfo a -> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserInfo a -> IO a
forall a. ParserInfo a -> IO a
OA.execParser
customExecParser ::
(HasCallStack, Optparse :> es) =>
ParserPrefs ->
ParserInfo a ->
Eff es a
customExecParser :: forall (es :: [Effect]) a.
(HasCallStack, Optparse :> es) =>
ParserPrefs -> ParserInfo a -> Eff es a
customExecParser ParserPrefs
prefs = IO a -> Eff es a
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO a -> Eff es a)
-> (ParserInfo a -> IO a) -> ParserInfo a -> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserPrefs -> ParserInfo a -> IO a
forall a. ParserPrefs -> ParserInfo a -> IO a
OA.customExecParser ParserPrefs
prefs
handleParseResult :: (HasCallStack, Optparse :> es) => ParserResult a -> Eff es a
handleParseResult :: forall (es :: [Effect]) a.
(HasCallStack, Optparse :> es) =>
ParserResult a -> Eff es a
handleParseResult = IO a -> Eff es a
forall a (es :: [Effect]). IO a -> Eff es a
unsafeEff_ (IO a -> Eff es a)
-> (ParserResult a -> IO a) -> ParserResult a -> Eff es a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserResult a -> IO a
forall a. ParserResult a -> IO a
OA.handleParseResult