Hoogle Search
Within LTS Haskell 24.38 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
slistToMaybe :: Slist a -> Maybe aslist Slist Returns Nothing on an empty list or Just a where a is the first element of the slist.
Examples
Basic usage:>>> slistToMaybe mempty Nothing
>>> slistToMaybe (one 42) Just 42
>>> slistToMaybe (cons 1 $ cons 2 $ one 3) Just 1
Laws :slistToMaybe . maybeToList ≡ id
Reverse is right only on singleton/empty listsmaybeToList . slistToMaybe {empty, singleton slist} ≡ {empty, singleton slist}catMaybes :: Slist (Maybe a) -> Slist aslist Slist.Maybe Takes a slist of Maybes and returns a slist of all the Just values.
>>> catMaybes (cons (Just 1) $ cons Nothing $ one $ Just 3) Slist {sList = [1,3], sSize = Size 2}mapMaybe :: forall b a . (a -> Maybe b) -> Slist a -> Slist bslist Slist.Maybe The Maybe version of map which can throw out elements. If appliying the given function returns Nothing, no element is added on to the result list. If it is Just b, then b is included in the result list.
>>> maybeEven x = if even x then Just x else Nothing >>> s = cons 1 $ cons 2 $ one 3
>>> mapMaybe maybeEven s Slist {sList = [2], sSize = Size 1}If we map the Just constructor, the entire list should be returned:>>> mapMaybe Just s Slist {sList = [1,2,3], sSize = Size 3}slistToMaybe :: Slist a -> Maybe aslist Slist.Maybe Returns Nothing on an empty list or Just a where a is the first element of the slist.
Examples
Basic usage:>>> slistToMaybe mempty Nothing
>>> slistToMaybe (one 42) Just 42
>>> slistToMaybe (cons 1 $ cons 2 $ one 3) Just 1
Laws :slistToMaybe . maybeToList ≡ id
Reverse is right only on singleton/empty listsmaybeToList . slistToMaybe {empty, singleton slist} ≡ {empty, singleton slist}boolToMaybe :: Bool -> a -> Maybe aspacecookie Network.Gopher.Util boolToMaybe True x == Just x
boolToMaybe False x == Nothing
-
stratosphere Stratosphere.ResourceImports The catMaybes function takes a list of Maybes and returns a list of all the Just values.
Examples
Basic usage:>>> catMaybes [Just 1, Nothing, Just 3] [1,3]
When constructing a list of Maybe values, catMaybes can be used to return all of the "success" results (if the list is the result of a map, then mapMaybe would be more appropriate):>>> import GHC.Internal.Text.Read ( readMaybe ) >>> [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ] [Just 1,Nothing,Just 3] >>> catMaybes $ [readMaybe x :: Maybe Int | x <- ["1", "Foo", "3"] ] [1,3]
-
streamly Streamly.Internal.Data.Stream.IsStream In a stream of Maybes, discard Nothings and unwrap Justs. Pre-release
-
streamly Streamly.Internal.Data.Stream.IsStream Map a Maybe returning function to a stream, filter out the Nothing elements, and return a stream of values extracted from Just. Equivalent to:
mapMaybe f = Stream.map fromJust . Stream.filter isJust . Stream.map f
mapMaybeM :: (IsStream t, MonadAsync m, Functor (t m)) => (a -> m (Maybe b)) -> t m a -> t m bstreamly Streamly.Internal.Data.Stream.IsStream Like mapMaybe but maps a monadic function. Equivalent to:
mapMaybeM f = Stream.map fromJust . Stream.filter isJust . Stream.mapM f
Concurrent (do not use with fromParallel on infinite streams)-
streamly Streamly.Internal.Network.Socket Write a stream of Maybe values. Keep buffering the Just values in an array. Write the array to the Handle as soon as a Nothing is encountered or the buffer size exceeds the specified limit. Pre-release