-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A collection of commonly used utils -- -- A collection of commonly used util functions for basic libaries @package util-plus @version 0.1.0.0 -- | Helper functions for dealing with call stacks and source locations. module GHC.Stack.Plus callerLocation :: (HasCallStack) => String -- | The filename of the first caller which called a function with implicit -- parameter (callStack :: CallStack). callerFile :: (HasCallStack) => String -- | The line number of the first caller which called a function with -- implicit parameter (callStack :: CallStack). callerLine :: (HasCallStack) => Int adjustSourceFilePath :: FilePath -> FilePath module Safe.Plus -- | The filename of the first caller which called a function with implicit -- parameter (callStack :: CallStack). callerFile :: (HasCallStack) => String -- | The line number of the first caller which called a function with -- implicit parameter (callStack :: CallStack). callerLine :: (HasCallStack) => Int callerLocation :: (HasCallStack) => String -- | Convert a single digit Char to the corresponding Int. -- This function fails unless its argument satisfies isHexDigit, -- but recognises both upper and lower-case hexadecimal digits (i.e. -- '0'..'9', 'a'..'f', -- 'A'..'F'). safeDigitToInt :: Monad m => Char -> m Int safeRead :: (HasCallStack, Read a) => String -> a readNoteVerbose :: Read a => String -> String -> a safeFromJust :: (HasCallStack) => Maybe a -> a safeFromJustNote :: (HasCallStack) => String -> Maybe a -> a safeHead :: (HasCallStack) => [a] -> a safeTail :: (HasCallStack) => [a] -> [a] safeInit :: (HasCallStack) => [a] -> [a] safeLast :: (HasCallStack) => [a] -> a safeMaximum :: (HasCallStack, Ord a) => [a] -> a safeMinimum :: (HasCallStack, Ord a) => [a] -> a safeHeadNote :: (HasCallStack) => String -> [a] -> a safeFromRight :: (HasCallStack) => Either a b -> b fromRightNote :: String -> Either a b -> b safeFromLeft :: (HasCallStack) => Either a b -> a fromLeftNote :: String -> Either a b -> a safeAtArray :: (HasCallStack, IArray a e, Ix i, Show i) => a i e -> i -> e atArrayNote :: (IArray a e, Ix i, Show i) => String -> a i e -> i -> e safeAt :: (HasCallStack) => [a] -> Int -> a safeError :: (HasCallStack) => String -> a safeFail :: (HasCallStack, Monad m) => String -> m a safeUndef :: (HasCallStack) => a module Data.List.Plus -- | 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 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]
--   
catMaybes :: [Maybe a] -> [a] chunksOf :: Int -> [a] -> [[a]] extractLast :: a -> [a] -> ([a], a) groupOn :: Eq b => (a -> b) -> [a] -> [(b, [a])] groupOn' :: Eq b => (a -> (b, c)) -> [a] -> [(b, [c])] groupOnSort :: Ord b => (a -> b) -> [a] -> [(b, [a])] groupOnSort' :: Ord b => (a -> (b, c)) -> [a] -> [(b, [c])] groupBySort :: Ord b => (b -> b -> Ordering) -> (a -> b) -> [a] -> [(b, [a])] groupUnsortedOn :: forall a b. Eq b => (a -> b) -> [a] -> [(b, [a])] headM :: Monad m => [a] -> m a lastElems :: Int -> [a] -> [a] lastM :: Monad m => [a] -> m a lookupM :: (Eq a, Monad m) => (a -> String) -> a -> [(a, b)] -> m b makeMapping :: (Eq a, Hashable a) => [(a, b)] -> [(a, b)] -- | The mapMaybe function is a version of map which can -- throw out elements. In particular, the functional argument returns -- something of type Maybe b. If this is Nothing, -- no element is added on to the result list. If it is Just -- b, then b is included in the result list. -- --

Examples

-- -- Using mapMaybe f x is a shortcut for -- catMaybes $ map f x in most cases: -- --
--   >>> import Text.Read ( readMaybe )
--   
--   >>> let readMaybeInt = readMaybe :: String -> Maybe Int
--   
--   >>> mapMaybe readMaybeInt ["1", "Foo", "3"]
--   [1,3]
--   
--   >>> catMaybes $ map readMaybeInt ["1", "Foo", "3"]
--   [1,3]
--   
-- -- If we map the Just constructor, the entire list should be -- returned: -- --
--   >>> mapMaybe Just [1,2,3]
--   [1,2,3]
--   
mapMaybe :: (a -> Maybe b) -> [a] -> [b] maximumM :: (Monad m, Ord a) => [a] -> m a -- | Merge two sorted list so that the resulting list is sorted as well. -- and contains all elements from one of the lists. The length of the -- resulting list is the sum of the lengths of the given lists. merge :: Ord a => [a] -> [a] -> [a] -- | Computes the element in the middle of the list If the list has an even -- number of elements, you will get the element after the middle of the -- list. middle :: [a] -> Maybe a minimumM :: (Monad m, Ord a) => [a] -> m a monotone :: (Ord a) => [a] -> Bool -- | Merge the two sorted lists and remove all duplicates. nubMerge :: Ord a => [a] -> [a] -> [a] prefixesAndSuffixes :: [a] -> [([a], [a])] sconcatBy :: (Ord b, Foldable f, Semigroup s) => (a -> b) -> (a -> s) -> f a -> [(b, s)] spanTailRec :: (a -> Bool) -> [a] -> ([a], [a]) stripSuffix :: (Eq a) => [a] -> [a] -> Maybe [a] -- | Strips as elements of a given prefix list as possible. Stops stripping -- if the prefix doesn't match anymore or is exhausted and returns the -- remaining string. tryStripPrefix :: Eq a => [a] -> [a] -> [a] ungroupMay :: [(a, [b])] -> Maybe [(a, b)] withLast :: (a -> a) -> [a] -> [a] module Control.Applicative.Plus withOptional :: (Foldable t, Alternative t) => (a -> (b -> m c) -> m c) -> t a -> (t b -> m c) -> m c -- | A generalized version of optional that works with -- Option for example optional' :: (MonadPlus t, Alternative f) => f a -> f (t a)