Hoogle Search

Within LTS Haskell 24.6 (ghc-9.10.2)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. maybeOption :: a -> Bool -> (a -> a) -> Maybe a -> Maybe a

    configuration-tools Configuration.Utils.Maybe

    Command line parser for record Maybe values

    Example:

    data Setting = Setting
    { _setA ∷ !Int
    , _setB ∷ !String
    }
    deriving (Show, Read, Eq, Ord, Typeable)
    
    $(makeLenses ''Setting)
    
    defaultSetting ∷ Setting
    defaultSetting = Setting
    { _setA = 0
    , _setB = 1
    }
    
    instance ToJSON Setting where
    toJSON setting = object
    [ "a" .= _setA setting
    , "b" .= _setB setting
    ]
    
    instance FromJSON (Setting → Setting) where
    parseJSON = withObject "Setting" $ \o → id
    <$< setA ..: "a" % o
    <*< setB ..: "b" % o
    
    instance FromJSON Setting where
    parseJSON v = parseJSON v <*> pure defaultSetting
    
    pSetting ∷ MParser Setting
    pSetting = id
    <$< setA .:: option auto
    % short 'a'
    <> metavar "INT"
    <> help "set a"
    <*< setB .:: option auto
    % short 'b'
    <> metavar "INT"
    <> help "set b"
    
    -- | Use 'Setting' as 'Maybe' in a configuration:
    --
    data Config = Config
    { _maybeSetting ∷ !(Maybe Setting)
    }
    deriving (Show, Read, Eq, Ord, Typeable)
    
    $(makeLenses ''Config)
    
    defaultConfig ∷ Config
    defaultConfig = Config
    { _maybeSetting = defaultSetting
    }
    
    instance ToJSON Config where
    toJSON config = object
    [ "setting" .= maybeSetting
    ]
    
    instance FromJSON (Config → Config) where
    parseJSON = withObject "Config" $ \o → id
    <$< maybeSetting %.: "setting" % o
    
    pConfig ∷ MParser Config
    pConfig = id
    <$< maybeSetting %:: (maybeOption defaultSetting
    <$> pEnableSetting
    <*> pSetting)
    where
    pEnableSetting = boolOption
    % long "setting-enable"
    <> value False
    <> help "Enable configuration flags for setting"
    

  2. maybeHolds :: Property p v => p -> v -> Maybe v

    data-checked Data.Checked

    Return Just v if p holds and Nothing overwise.

  3. maybeHolds :: Property p v => p -> v -> Maybe v

    data-checked Data.Checked.Strict

    Return Just v if p holds and Nothing overwise.

  4. maybeM :: Monad m => m b -> (a -> m b) -> m (Maybe a) -> m b

    distribution-opensuse OpenSuse.Prelude

    Monadic generalisation of maybe.

  5. maybeToExceptS :: forall (m :: Type -> Type) a b . (Functor m, Monad m) => MSF (MaybeT m) a b -> MSF (ExceptT () m) a b

    dunai Control.Monad.Trans.MSF.Except

    Converts an MSF in MaybeT to an MSF in ExceptT. Whenever Nothing is thrown, throw () instead.

  6. maybeExit :: forall (m :: Type -> Type) a . Monad m => MSF (MaybeT m) (Maybe a) a

    dunai Control.Monad.Trans.MSF.Maybe

    Just a is passed along, Nothing causes the whole MSF to exit.

  7. maybeToExceptS :: forall (m :: Type -> Type) a b . (Functor m, Monad m) => MSF (MaybeT m) a b -> MSF (ExceptT () m) a b

    dunai Control.Monad.Trans.MSF.Maybe

    Converts an MSF in MaybeT to an MSF in ExceptT. Whenever Nothing is thrown, throw () instead.

  8. maybeToExceptT :: forall (m :: Type -> Type) e a . Functor m => e -> MaybeT m a -> ExceptT e m a

    dunai Control.Monad.Trans.MSF.Maybe

    Convert a MaybeT computation to ExceptT, with a default exception value.

  9. maybeModTime :: FilePath -> IO (Maybe UTCTime)

    dyre Config.Dyre.Paths

    Check if a file exists. If it exists, return Just the modification time. If it doesn't exist, return Nothing.

  10. maybeEither :: Maybe a -> Either () a

    errors-ext Control.Error.Extensions

    Converts Maybe to Either. Specialization of maybe.

    maybeEither . eitherMaybe = id
    

Page 50 of many | Previous | Next