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. maybeRead :: Read a => String -> Maybe a

    cabal-debian Debian.Debianize.Prelude

    No documentation available.

  2. maybeDecompress :: ByteString -> ByteString

    cabal-install Distribution.Client.GZipUtils

    Attempts to decompress the bytes under the assumption that "data format" error at the very beginning of the stream means that it is already decompressed. Caller should make sanity checks to verify that it is not, in fact, garbage. This is to deal with http proxies that lie to us and transparently decompress without removing the content-encoding header. See: https://github.com/haskell/cabal/issues/678

  3. maybeRepoRemote :: Repo -> Maybe RemoteRepo

    cabal-install Distribution.Client.Types.Repo

    Extract RemoteRepo from Repo if remote.

  4. maybeColor :: Handle -> [SGR] -> String -> IO String

    cabal2nix Distribution.Nixpkgs.Color

    If the given Handle should be colored, wrap a String in SGR codes.

  5. maybeBuildTopEntity :: Maybe String -> Name -> Q (TExp (Maybe TopEntity))

    clash-prelude Clash.Annotations.TH

    Return a typed 'Maybe TopEntity' expression given a Name. This will return an TExp of Nothing if TopEntity generation failed.

  6. maybeHasX :: (NFData a, NFDataX a) => a -> Maybe a

    clash-prelude Clash.XException

    Fully evaluate a value, returning Nothing if it throws XException. Note that non-XException errors take precedence over XException ones.

    maybeHasX 42                    = Just 42
    maybeHasX (XException msg)      = Nothing
    maybeHasX (3, XException msg)   = Nothing
    maybeHasX (XException msg, _|_) = _|_
    maybeHasX (_|_, XException msg) = _|_
    maybeHasX (3, _|_)              = _|_
    maybeHasX _|_                   = _|_
    

  7. maybeIsX :: a -> Maybe a

    clash-prelude Clash.XException

    Evaluate a value to WHNF, returning Nothing if it throws XException.

    maybeIsX 42                  = Just 42
    maybeIsX (XException msg)    = Nothing
    maybeIsX (3, XException msg) = Just (3, XException msg)
    maybeIsX (3, _|_)            = Just (3, _|_)
    maybeIsX _|_                 = _|_
    

  8. maybeX :: (String -> b) -> (a -> b) -> MaybeX a -> b

    clash-prelude Clash.XException.MaybeX

    Map functions over both constructors.

  9. maybeReader :: (String -> Maybe a) -> ReadM a

    configuration-tools Configuration.Utils.CommandLine

    Convert a function producing a Maybe into a reader.

  10. 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"
    

Page 64 of many | Previous | Next