Alternative f => [f a] -> f a +base

asum :: (Foldable t, Alternative f) => t (f a) -> f a
base Data.Foldable
The sum of a collection of actions, generalizing concat.
msum :: MonadPlus m => [m a] -> m a
base Control.Monad
This generalizes the list-based concat function.
(<|>) :: Alternative f => f a -> f a -> f a
base Control.Applicative
choice :: [ReadP a] -> ReadP a
base Text.ParserCombinators.ReadP
Combines all parsers in the specified list.
choice :: [ReadPrec a] -> ReadPrec a
base Text.ParserCombinators.ReadPrec
Combines all parsers in the specified list.
concat :: [[a]] -> [a]
base Prelude, base Data.List
Concatenate a list of lists.
msum :: (Foldable t, MonadPlus m) => t (m a) -> m a
base Data.Foldable
The sum of a collection of actions, generalizing concat.
intercalate :: [a] -> [[a]] -> [a]
base Data.List
intercalate xs xss is equivalent to (concat (intersperse xs xss)). It inserts the list xs in between the lists in xss and concatenates the result.
sequence_ :: Monad m => [m a] -> m ()
base Prelude, base Control.Monad
Evaluate each action in the sequence from left to right, and ignore the results.
nmergeIO :: [[a]] -> IO [a]
base Control.Concurrent
transpose :: [[a]] -> [[a]]
base Data.List
The transpose function transposes the rows and columns of its argument. For example, > transpose [[1,2,3],[4,5,6]] == [[1,4],[2,5],[3,6]]
concat :: Foldable t => t [a] -> [a]
base Data.Foldable
The concatenation of all the elements of a container of lists.
optional :: Alternative f => f a -> f (Maybe a)
base Control.Applicative
One or none.
many :: Alternative f => f a -> f [a]
base Control.Applicative
some :: Alternative f => f a -> f [a]
base Control.Applicative
block :: IO a -> IO a
base Control.Exception.Base, base Control.Exception, base Control.OldException
Note: this function is deprecated, please use mask instead. Applying block to a computation will execute that computation with asynchronous exceptions blocked. That is, any thread which attempts to raise an exception in the current thread with Control.Exception.throwTo will be blocked until asynchronous exceptions are unblocked again. There's no need to worry about re-enabling asynchronous exceptions; that is done automatically on exiting the scope of block. Threads created by Control.Concurrent.forkIO inherit the blocked state from the parent; that is, to start a thread in blocked mode, use block $ forkIO .... This is particularly useful if you need to establish an exception handler in the forked thread before any asynchronous exceptions are received.
mask_ :: IO a -> IO a
base Control.Exception.Base, base Control.Exception
Like mask, but does not pass a restore action to the argument.
runInBoundThread :: IO a -> IO a
base Control.Concurrent
Run the IO computation passed as the first argument. If the calling thread is not bound, a bound thread is created temporarily. runInBoundThread doesn't finish until the IO computation finishes. You can wrap a series of foreign function calls that rely on thread-local state with runInBoundThread so that you can use them without knowing whether the current thread is bound.
runInUnboundThread :: IO a -> IO a
base Control.Concurrent
Run the IO computation passed as the first argument. If the calling thread is bound, an unbound thread is created temporarily using forkIO. runInBoundThread doesn't finish until the IO computation finishes. Use this function only in the rare case that you have actually observed a performance loss due to the use of bound threads. A program that doesn't need it's main thread to be bound and makes heavy use of concurrency (e.g. a web server), might want to wrap it's main action in runInUnboundThread. Note that exceptions which are thrown to the current thread are thrown in turn to the thread that is executing the given computation. This ensures there's always a way of killing the forked thread.
unblock :: IO a -> IO a
base Control.Exception.Base, base Control.Exception, base Control.OldException
Note: this function is deprecated, please use mask instead. To re-enable asynchronous exceptions inside the scope of block, unblock can be used. It scopes in exactly the same way, so on exit from unblock asynchronous exception delivery will be disabled again.
uninterruptibleMask_ :: IO a -> IO a
base Control.Exception.Base, base Control.Exception
Like uninterruptibleMask, but does not pass a restore action to the argument.
unsafeInterleaveIO :: IO a -> IO a
base System.IO.Unsafe
unsafeInterleaveIO allows IO computation to be deferred lazily. When passed a value of type IO a, the IO will only be performed when the value of the a is demanded. This is used to implement lazy file reading, see System.IO.hGetContents.
parens :: ReadPrec a -> ReadPrec a
base Text.Read
(parens p) parses "P", "(P0)", "((P0))", etc, p parses "P" in the current precedence context and parses "P0" in precedence context zero
reset :: ReadPrec a -> ReadPrec a
base Text.ParserCombinators.ReadPrec
Resets the precedence context to zero.
step :: ReadPrec a -> ReadPrec a
base Text.ParserCombinators.ReadPrec
Increases the precedence context by one.
cycle :: [a] -> [a]
base Prelude, base Data.List
cycle ties a finite list into a circular one, or equivalently, the infinite repetition of the original list. It is the identity on infinite lists.
init :: [a] -> [a]
base Prelude, base Data.List
Return all the elements of a list except the last one. The list must be non-empty.
reverse :: [a] -> [a]
base Prelude, base Data.List
reverse xs returns the elements of xs in reverse order. xs must be finite.
tail :: [a] -> [a]
base Prelude, base Data.List
Extract the elements after the head of a list, which must be non-empty.
unlines :: [String] -> String
base Prelude, base Data.List, base Data.String
unlines is an inverse operation to lines. It joins lines, after appending a terminating newline to each.
unwords :: [String] -> String
base Prelude, base Data.List, base Data.String
unwords is an inverse operation to words. It joins words with separating spaces.
join :: Monad m => m (m a) -> m a
base Control.Monad
The join function is the conventional monad join operator. It is used to remove one level of monadic structure, projecting its bound argument into the outer level.
(<*) :: Applicative f => f a -> f b -> f a
base Control.Applicative
mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a
base Control.Monad
Direct MonadPlus equivalent of filter filter = (mfilter:: (a -> Bool) -> [a] -> [a] applicable to any MonadPlus, for example mfilter odd (Just 1) == Just 1 mfilter odd (Just 2) == Nothing
mplus :: MonadPlus m => m a -> m a -> m a
base Control.Monad
(*>) :: Applicative f => f a -> f b -> f b
base Control.Applicative
(>>) :: Monad m => m a -> m b -> m b
base Prelude, base Control.Monad, base Control.Monad.Instances
sequenceA_ :: (Foldable t, Applicative f) => t (f a) -> f ()
base Data.Foldable
Evaluate each action in the structure from left to right, and ignore the results.
sequence_ :: (Foldable t, Monad m) => t (m a) -> m ()
base Data.Foldable
Evaluate each monadic action in the structure from left to right, and ignore the results.
sequence :: Monad m => [m a] -> m [a]
base Prelude, base Control.Monad
Evaluate each action in the sequence from left to right, and collect the results.
handle :: Exception e => (e -> IO a) -> IO a -> IO a
base Control.Exception.Base, base Control.Exception
A version of catch with the arguments swapped around; useful in situations > do handle (\NonTermination -> exitWith (ExitFailure 1)) $ > ...
handle :: (Exception -> IO a) -> IO a -> IO a
base Control.OldException
A version of catch with the arguments swapped around; useful in situations > do handle (\e -> exitWith (ExitFailure 1)) $ > ...
catchDyn :: Typeable exception => IO a -> (exception -> IO a) -> IO a
base Control.OldException
Catch dynamic exceptions of the required type. All other exceptions are re-thrown, including dynamic exceptions of the wrong type. When using dynamic exceptions it is advisable to define a new datatype to use for your exception type, to avoid possible clashes with dynamic exceptions used in other libraries.
catch :: Exception e => IO a -> (e -> IO a) -> IO a
base Control.Exception.Base, base Control.Exception
This is the simplest of the exception-catching functions. It takes a single argument, runs it, and if an exception is raised the "handler" is executed, with the value of the exception passed as an argument. Otherwise, the result is returned as normal. For example: > catch (readFile f) > (\e -> do let err = show (e :: IOException) > hPutStr stderr ("Warning: Couldn't open " ++ f ++ ": " ++ err) > return "") Note that we have to give a type signature to e, or the program will not typecheck as the type is ambiguous. While it is possible to catch exceptions of any type, see the previous section "Catching all exceptions" for an explanation of the problems with doing so. For catching exceptions in pure (non-IO) expressions, see the function evaluate. Note that due to Haskell's unspecified evaluation order, an expression may throw one of several possible exceptions: consider the expression (error "urk") + (1 `div` 0). Does the expression throw ErrorCall "urk", or DivideByZero? The answer is "it might throw either"; the choice is non-deterministic. If you are catching any type of exception then you might catch either. If you are calling catch with type IO Int -> (ArithException -> IO Int) -> IO Int then the handler may get run with DivideByZero as an argument, or an ErrorCall "urk" exception may be propogated further up. If you call it again, you might get a the opposite behaviour. This is ok, because catch is an IO computation. Note that the Prelude also exports a function called Prelude.catch with a similar type to Control.Exception.catch, except that the Prelude version only catches the IO and user families of exceptions (as required by Haskell 98). We recommend either hiding the Prelude version of Prelude.catch when importing Control.Exception: > import Prelude hiding (catch) or importing Control.Exception qualified, to avoid name-clashes: > import qualified Control.Exception as C and then using C.catch
catch :: IO a -> (Exception -> IO a) -> IO a
base Control.OldException
This is the simplest of the exception-catching functions. It takes a single argument, runs it, and if an exception is raised the "handler" is executed, with the value of the exception passed as an argument. Otherwise, the result is returned as normal. For example: > catch (openFile f ReadMode) > (\e -> hPutStr stderr ("Couldn't open "++f++": " ++ show e)) For catching exceptions in pure (non-IO) expressions, see the function evaluate. Note that due to Haskell's unspecified evaluation order, an expression may return one of several possible exceptions: consider the expression error "urk" + 1 `div` 0. Does catch execute the handler passing ErrorCall "urk", or ArithError DivideByZero? The answer is "either": catch makes a non-deterministic choice about which exception to catch. If you call it again, you might get a different exception back. This is ok, because catch is an IO computation. Note that catch catches all types of exceptions, and is generally used for "cleaning up" before passing on the exception using throwIO. It is not good practice to discard the exception and continue, without first checking the type of the exception (it might be a ThreadKilled, for example). In this case it is usually better to use catchJust and select the kinds of exceptions to catch. Also note that the Prelude also exports a function called Prelude.catch with a similar type to catch, except that the Prelude version only catches the IO and user families of exceptions (as required by Haskell 98). We recommend either hiding the Prelude version of Prelude.catch when importing Control.OldException: > import Prelude hiding (catch) or importing Control.OldException qualified, to avoid name-clashes: > import qualified Control.OldException as C and then using C.catch
catches :: IO a -> [Handler a] -> IO a
base Control.Exception
Sometimes you want to catch two different sorts of exception. You could do something like > f = expr `catch` \ (ex :: ArithException) -> handleArith ex > `catch` \ (ex :: IOException) -> handleIO ex However, there are a couple of problems with this approach. The first is that having two exception handlers is inefficient. However, the more serious issue is that the second exception handler will catch exceptions in the first, e.g. in the example above, if handleArith throws an IOException then the second exception handler will catch it. Instead, we provide a function catches, which would be used thus: > f = expr `catches` [Handler (\ (ex :: ArithException) -> handleArith ex), > Handler (\ (ex :: IOException) -> handleIO ex)]
finally :: IO a -> IO b -> IO a
base Control.Exception.Base, base Control.Exception, base Control.OldException
A specialised variant of bracket with just a computation to run afterward.
onException :: IO a -> IO b -> IO a
base Control.Exception.Base, base Control.Exception
Like finally, but only performs the final action if there was an exception raised by the computation.
alignPtr :: Ptr a -> Int -> Ptr a
base Foreign.Ptr
Given an arbitrary address and an alignment constraint, alignPtr yields the next higher address that fulfills the alignment constraint. An alignment constraint x is fulfilled by any address divisible by x. This operation is idempotent.
option :: a -> ReadP a -> ReadP a
base Text.ParserCombinators.ReadP
option x p will either parse p or return x without consuming any input.
chainl1 :: ReadP a -> ReadP (a -> a -> a) -> ReadP a
base Text.ParserCombinators.ReadP
Like chainl, but parses one or more occurrences of p.
chainr1 :: ReadP a -> ReadP (a -> a -> a) -> ReadP a
base Text.ParserCombinators.ReadP
Like chainr, but parses one or more occurrences of p.
(+++) :: ReadP a -> ReadP a -> ReadP a
base Text.ParserCombinators.ReadP
Symmetric choice.
(<++) :: ReadP a -> ReadP a -> ReadP a
base Text.ParserCombinators.ReadP
Local, exclusive, left-biased choice: If left parser locally produces any result at all, then right parser is not used.
(+++) :: ReadPrec a -> ReadPrec a -> ReadPrec a
base Text.ParserCombinators.ReadPrec
Symmetric choice.
(<++) :: ReadPrec a -> ReadPrec a -> ReadPrec a
base Text.ParserCombinators.ReadPrec
Local, exclusive, left-biased choice: If left parser locally produces any result at all, then right parser is not used.
catchSTM :: Exception e => STM a -> (e -> STM a) -> STM a
base GHC.Conc.Sync, base GHC.Conc
Exception handling within STM actions.
orElse :: STM a -> STM a -> STM a
base GHC.Conc.Sync, base GHC.Conc
Compose two alternative STM actions (GHC only). If the first action completes without retrying then it forms the result of the orElse. Otherwise, if the first action retries, then the second action is tried in its place. If both actions retry then the orElse as a whole retries.
augment :: (forall b. (a -> b -> b) -> b -> b) -> [a] -> [a]
base GHC.Exts
A list producer that can be fused with foldr. This function is merely > augment g xs = g (:) xs but GHC's simplifier will transform an expression of the form foldr k z (augment g xs), which may arise after inlining, to g k (foldr k z xs), which avoids producing an intermediate list.
sortWith :: Ord b => (a -> b) -> [a] -> [a]
base GHC.Exts
The sortWith function sorts a list of elements using the user supplied function to project something out of each element

Show more results