Hoogle Search
Within LTS Haskell 24.4 (ghc-9.10.2)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
maybeH :: Monad m => Maybe v -> (v -> m ()) -> Maybe (m ()) -> m ()shakespeare Text.Hamlet Runs the second argument with the value in the first, if available. Otherwise, runs the third argument, if available.
-
errors Control.Error The maybeToList function returns an empty list when given Nothing or a singleton list when given Just.
Examples
Basic usage:>>> maybeToList (Just 7) [7]
>>> maybeToList Nothing []
One can use maybeToList to avoid pattern matching when combined with a function that (safely) works on lists:>>> import GHC.Internal.Text.Read ( readMaybe ) >>> sum $ maybeToList (readMaybe "3") 3 >>> sum $ maybeToList (readMaybe "") 0
maybeT :: Monad m => m b -> (a -> m b) -> MaybeT m a -> m berrors Control.Error.Util Case analysis for MaybeT Use the first argument if the MaybeT computation fails, otherwise apply the function to the successful result.
maybeEntropy :: MaybeEntropy d => d -> Maybe Doublestatistics Statistics.Distribution Returns the entropy of a distribution, in nats, if such is defined.
maybeMean :: MaybeMean d => d -> Maybe Doublestatistics Statistics.Distribution No documentation available.
maybeStdDev :: MaybeVariance d => d -> Maybe Doublestatistics Statistics.Distribution No documentation available.
maybeVariance :: MaybeVariance d => d -> Maybe Doublestatistics Statistics.Distribution No documentation available.
maybeModify :: Storable e => Vector s e -> Int -> (e -> e) -> ST s Boolstorablevector Data.StorableVector.ST.Strict Similar to maybeWrite. In future maybeModify will replace modify.
maybeRead :: Storable e => Vector s e -> Int -> ST s (Maybe e)storablevector Data.StorableVector.ST.Strict Returns Just e, when the element e could be read and Nothing if the index was out of range. This way you can avoid duplicate index checks that may be needed when using read.
Control.Monad.ST.runST (do arr <- new_ 10; Monad.zipWithM_ (write arr) [9,8..0] ['a'..]; read arr 3)
In future maybeRead will replace read.maybeWrite :: Storable e => Vector s e -> Int -> e -> ST s Boolstorablevector Data.StorableVector.ST.Strict Returns True if the element could be written and False if the index was out of range.
runSTVector (do arr <- new_ 10; foldr (\c go i -> maybeWrite arr i c >>= \cont -> if cont then go (succ i) else return arr) (error "unreachable") ['a'..] 0)
In future maybeWrite will replace write.