Hoogle Search
Within LTS Haskell 24.2 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
fromMaybe :: a -> Maybe a -> abasic-prelude CorePrelude The fromMaybe function takes a default value and a Maybe value. If the Maybe is Nothing, it returns the default value; otherwise, it returns the value contained in the Maybe.
Examples
Basic usage:>>> fromMaybe "" (Just "Hello, World!") "Hello, World!"
>>> fromMaybe "" Nothing ""
Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:>>> import GHC.Internal.Text.Read ( readMaybe ) >>> fromMaybe 0 (readMaybe "5") 5 >>> fromMaybe 0 (readMaybe "") 0
fromMaybe :: a -> Maybe a -> aclassy-prelude ClassyPrelude The fromMaybe function takes a default value and a Maybe value. If the Maybe is Nothing, it returns the default value; otherwise, it returns the value contained in the Maybe.
Examples
Basic usage:>>> fromMaybe "" (Just "Hello, World!") "Hello, World!"
>>> fromMaybe "" Nothing ""
Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:>>> import GHC.Internal.Text.Read ( readMaybe ) >>> fromMaybe 0 (readMaybe "5") 5 >>> fromMaybe 0 (readMaybe "") 0
fromMaybe :: a -> Maybe a -> aghc-lib-parser GHC.Data.Strict No documentation available.
fromMaybe :: (Steppable (->) t (Either a), Corecursive (->) t (Either a)) => Maybe a -> tyaya Yaya.Applied Converts exceptional divergence to non-termination.
fromMaybe :: a -> Maybe a -> afoundation Foundation The fromMaybe function takes a default value and a Maybe value. If the Maybe is Nothing, it returns the default value; otherwise, it returns the value contained in the Maybe.
Examples
Basic usage:>>> fromMaybe "" (Just "Hello, World!") "Hello, World!"
>>> fromMaybe "" Nothing ""
Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:>>> import GHC.Internal.Text.Read ( readMaybe ) >>> fromMaybe 0 (readMaybe "5") 5 >>> fromMaybe 0 (readMaybe "") 0
fromMaybe :: a -> Maybe a -> amassiv-test Test.Massiv.Utils The fromMaybe function takes a default value and a Maybe value. If the Maybe is Nothing, it returns the default value; otherwise, it returns the value contained in the Maybe.
Examples
Basic usage:>>> fromMaybe "" (Just "Hello, World!") "Hello, World!"
>>> fromMaybe "" Nothing ""
Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:>>> import GHC.Internal.Text.Read ( readMaybe ) >>> fromMaybe 0 (readMaybe "5") 5 >>> fromMaybe 0 (readMaybe "") 0
-
relational-query Database.Relational.Arrow Operator from maybe type using record extended isNull.
-
relational-query Database.Relational.Projectable Operator from maybe type using record extended isNull.
fromMaybe :: a -> Maybe a -> acabal-install-solver Distribution.Solver.Compat.Prelude The fromMaybe function takes a default value and a Maybe value. If the Maybe is Nothing, it returns the default value; otherwise, it returns the value contained in the Maybe.
Examples
Basic usage:>>> fromMaybe "" (Just "Hello, World!") "Hello, World!"
>>> fromMaybe "" Nothing ""
Read an integer from a string using readMaybe. If we fail to parse an integer, we want to return 0 by default:>>> import GHC.Internal.Text.Read ( readMaybe ) >>> fromMaybe 0 (readMaybe "5") 5 >>> fromMaybe 0 (readMaybe "") 0
fromMaybe :: forall c (f :: Type -> Type) a . c -> Colonnade f a c -> Colonnade f (Maybe a) ccolonnade Colonnade Lift a column over a Maybe. For example, if some people have houses and some do not, the data that pairs them together could be represented as:
>>> :{ let owners :: [(Person,Maybe House)] owners = [ (Person "Jordan" 18, Nothing) , (Person "Ruth" 25, Just (House Red 125000)) , (Person "Sonia" 12, Just (House Green 145000)) ] :}
The column encodings defined earlier can be reused with the help of fromMaybe:>>> :{ let colOwners :: Colonnade Headed (Person,Maybe House) String colOwners = mconcat [ lmap fst colPerson , lmap snd (fromMaybe "" colHouse) ] :}
>>> putStr (ascii colOwners owners) +--------+-----+-------+---------+ | Name | Age | Color | Price | +--------+-----+-------+---------+ | Jordan | 18 | | | | Ruth | 25 | Red | $125000 | | Sonia | 12 | Green | $145000 | +--------+-----+-------+---------+