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.

  1. slistToMaybe :: Slist a -> Maybe a

    slist 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 lists
    maybeToList . slistToMaybe {empty, singleton slist} ≡ {empty, singleton slist}
    

  2. catMaybes :: Slist (Maybe a) -> Slist a

    slist 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}
    

  3. mapMaybe :: forall b a . (a -> Maybe b) -> Slist a -> Slist b

    slist 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}
    

  4. slistToMaybe :: Slist a -> Maybe a

    slist 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 lists
    maybeToList . slistToMaybe {empty, singleton slist} ≡ {empty, singleton slist}
    

  5. boolToMaybe :: Bool -> a -> Maybe a

    spacecookie Network.Gopher.Util

    boolToMaybe True x == Just x
    
    boolToMaybe False x == Nothing
    

  6. catMaybes :: [Maybe a] -> [a]

    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]
    

  7. catMaybes :: forall t (m :: Type -> Type) a . (IsStream t, Monad m, Functor (t m)) => t m (Maybe a) -> t m a

    streamly Streamly.Internal.Data.Stream.IsStream

    In a stream of Maybes, discard Nothings and unwrap Justs. Pre-release

  8. mapMaybe :: forall t (m :: Type -> Type) a b . (IsStream t, Monad m) => (a -> Maybe b) -> t m a -> t m b

    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
    

  9. mapMaybeM :: (IsStream t, MonadAsync m, Functor (t m)) => (a -> m (Maybe b)) -> t m a -> t m b

    streamly 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)

  10. writeMaybesWith :: forall (m :: Type -> Type) . MonadIO m => Int -> Socket -> Fold m (Maybe Word8) ()

    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

Page 286 of many | Previous | Next