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.
isElmMaybeType :: EType -> Boolservant-elm Servant.Elm.Internal.Generate No documentation available.
parseMaybe :: (Ord e, Stream s) => Parsec e s a -> s -> Maybe ashellwords 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.
catMaybes :: Slist (Maybe a) -> Slist aslist 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}mapMaybe :: forall b a . (a -> Maybe b) -> Slist a -> Slist bslist 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}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]