Hoogle Search

Within LTS Haskell 24.46 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. isElmMaybeType :: EType -> Bool

    servant-elm Servant.Elm.Internal.Generate

    No documentation available.

  2. parseMaybe :: (Ord e, Stream s) => Parsec e s a -> s -> Maybe a

    shellwords Text.Megaparsec.Compat

    parseMaybe p input runs the parser p on input and returns the result inside Just on success and Nothing on failure. This function also parses eof, so if the parser doesn't consume all of its input, it will fail. The function is supposed to be useful for lightweight parsing, where error messages (and thus file names) are not important and entire input should be consumed. For example, it can be used for parsing of a single number according to a specification of its format.

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

    slist Slist

    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}
    

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

    slist Slist

    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}
    

  5. 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}
    

  6. 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}
    

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

  8. 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}
    

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

    spacecookie Network.Gopher.Util

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

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

Page 290 of many | Previous | Next