Basic string-manipulation and other functions they forgot to put in the standard prelude.
- trimTrailing :: String -> String
- trimLeading :: String -> String
- trimSpaces :: String -> String
- padToLength :: Int -> String -> String
- monadDot :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- simpleSplit :: (a -> Bool) -> [a] -> [[a]]
- findJust :: (a -> Maybe b) -> [a] -> Maybe b
- insertOrdLt :: Ord a => a -> [a] -> [a]
- insertOrdGt :: Ord a => a -> [a] -> [a]
- insertOrd :: (a -> a -> Bool) -> a -> [a] -> [a]
- insertOrdAlternate :: (a -> a -> Ordering) -> a -> (a -> a) -> [a] -> [a]
- bottom :: a
- readCheck :: Read a => String -> Maybe a
- chop :: Int -> [a] -> Maybe [a]
- pairList :: a -> [b] -> [(a, b)]
- lastOpt :: [a] -> Maybe a
- isPrefix :: Eq a => [a] -> [a] -> Maybe [a]
- class HasCoMapIO option where
- class HasMapIO option where
- class HasMapMonadic h where
- mapPartialM :: Monad m => (a -> m (Maybe b)) -> [a] -> m [b]
- splitByChar :: Char -> String -> [String]
- unsplitByChar :: Char -> [String] -> String
- unsplitByChar0 :: Char -> [String] -> String
- splitToChar :: Char -> String -> Maybe (String, String)
- splitToElem :: (a -> Bool) -> [a] -> Maybe ([a], [a])
- splitToElemGeneral :: (a -> Bool) -> [a] -> Maybe ([a], a, [a])
- deleteFirst :: (a -> Bool) -> [a] -> [a]
- deleteFirstOpt :: (a -> Bool) -> [a] -> [a]
- deleteAndFindFirst :: (a -> Bool) -> [a] -> (a, [a])
- deleteAndFindFirstOpt :: (a -> Bool) -> [a] -> Maybe (a, [a])
- divideList :: (a -> Either b c) -> [a] -> ([b], [c])
- treeFold :: (ancestorInfo -> state -> node -> (ancestorInfo, state, [node])) -> ancestorInfo -> state -> node -> state
- treeFoldM :: Monad m => (ancestorInfo -> state -> node -> m (ancestorInfo, state, [node])) -> ancestorInfo -> state -> node -> m state
- mapEq :: Eq a => (b -> a) -> b -> b -> Bool
- mapOrd :: Ord a => (b -> a) -> b -> b -> Ordering
- type BreakFn = forall other. String -> other
- addFallOut :: (BreakFn -> IO a) -> IO (Either String a)
- addFallOutWE :: (BreakFn -> IO a) -> IO (WithError a)
- addSimpleFallOut :: IO a -> IO (Either String a)
- simpleFallOut :: BreakFn
- mkBreakFn :: ObjectID -> BreakFn
- newFallOut :: IO (ObjectID, IO a -> IO (Either String a))
- isOurFallOut :: ObjectID -> Dyn -> Maybe String
- addGeneralFallOut :: Typeable a => IO (GeneralBreakFn a, GeneralCatchFn a)
- data GeneralBreakFn a = GeneralBreakFn (forall b. a -> b)
- data GeneralCatchFn a = GeneralCatchFn (forall c. IO c -> IO (Either a c))
- catchOurExceps :: IO a -> IO (Either String a)
- catchAllExceps :: IO a -> IO (Either String a)
- errorOurExceps :: IO a -> IO a
- ourExcepToMess :: Dyn -> Maybe String
- breakOtherExceps :: BreakFn -> IO a -> IO a
- showException2 :: Dyn -> String
- class EqIO v where
- class EqIO v => OrdIO v where
- newtype Full a = Full a
- uniqOrd :: Ord a => [a] -> [a]
- uniqOrdOrder :: Ord a => [a] -> [a]
- uniqOrdByKey :: Ord b => (a -> b) -> [a] -> [a]
- uniqOrdByKeyOrder :: Ord b => (a -> b) -> [a] -> [a]
- allSame :: (a -> Bool) -> [a] -> Maybe Bool
- allEq :: Eq a => [a] -> Bool
- findDuplicate :: Ord a => (b -> a) -> [b] -> Maybe b
- generalisedMerge :: Monad m => [a] -> [b] -> (a -> b -> Ordering) -> (Maybe a -> Maybe b -> m (Maybe a, Maybe c)) -> m ([a], [c])
Trimming spaces from Strings and putting them back again.
Remove trailing spaces (We try to avoid reconstructing the string, on the assumption that there aren't often spaces)
Pad a string if necessary to the given length with leading spaces.
The . operator lifted to monads. So like ., the arguments are given in the reverse order to that in which they should be executed.
insertOrdAlternate is similar to insertOrd except (1) it takes an Ordering argument; (2) if it finds an argument that matches, it applies the given function to generate a new element, rather than inserting another. The new generated element should be EQ to the old one.
returns Just a if we can read a, and the rest is just spaces.
returns remainder if the first list is a prefix of the second one.
Miscellaneous string and list operations
We split at the first occurrence of the character, returning the string before and after.
Folding on trees
node is the tree's node type. state is folded through every node of the tree (and is the result). We search the tree in depth-first order, applying visitNode at each node to update the state. The ancestorInfo information comes from the ancestors of the node. EG if we are visiting node N1 which came from N2 the ancestorInfo given to visitNode for N1 will be that computed from visitNode for N2. For the root node, it will be initialAncestor
Like treeFold, but using monads.
Exception-driven error mechanism.
A function indicating we want to escape from the current computation.
Intended use, EG addFallOut ( break -> do -- blah blah (normal IO a stuff) -- when (break condition) (break You can't do that there ere) -- more blah blah, not executed if there's an break -- return (value of type a) )
Like addFallOut, but returns a WithError object instead.
Other miscellaneous functions
indicates that an Ord or Eq instance really does need to take everything into account.
Like uniqOrd, except that we specify the output order of the list. The resulting list is that obtained by deleting all duplicate elements in the list, except the first, for example [1,2,3,2,1,4] will go to [1,2,3,4].
Remove duplicate elements from a list where the key function is supplied.
Remove duplicate elements from a list where the key function is supplied. The list order is preserved and of the duplicates, it is the first in the list which is not deleted.
Return Just True if all the elements give True, Just False if all False, Nothing otherwise (or list is empty).
If there are two elements of the list with the same (a), return one, otherwise Nothing.
|:: Monad m|
list to combine with input list
|-> (a -> b -> Ordering)|
comparison function. a and b should be already sorted consistently with this comparison function, and it is assumed that each list is EQ to at most one of the other.
|-> (Maybe a -> Maybe b -> m (Maybe a, Maybe c))|
Merge function applied to each element of a and b, where we pair EQ elements together.
|-> m ([a], [c])|
Output of merge function concatenated.
A merge function for combining an input list with some new data, where both are pre-sorted.