Safe Haskell | None |
---|
- withNumCapabilities :: Int -> IO a -> IO a
- setNumCapabilities :: Int -> IO ()
- retry :: Int -> IO a -> IO a
- showException :: SomeException -> IO String
- ignore :: IO () -> IO ()
- catch_ :: IO a -> (SomeException -> IO a) -> IO a
- handle_ :: (SomeException -> IO a) -> IO a -> IO a
- try_ :: IO a -> IO (Either SomeException a)
- catchJust_ :: (SomeException -> Maybe b) -> IO a -> (b -> IO a) -> IO a
- handleJust_ :: (SomeException -> Maybe b) -> (b -> IO a) -> IO a -> IO a
- tryJust_ :: (SomeException -> Maybe b) -> IO a -> IO (Either b a)
- catchBool :: Exception e => (e -> Bool) -> IO a -> (e -> IO a) -> IO a
- handleBool :: Exception e => (e -> Bool) -> (e -> IO a) -> IO a -> IO a
- tryBool :: Exception e => (e -> Bool) -> IO a -> IO (Either e a)
- whenJust :: Applicative m => Maybe a -> (a -> m ()) -> m ()
- unit :: m () -> m ()
- partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])
- concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b]
- loopM :: Monad m => (a -> m (Either a b)) -> a -> m b
- whileM :: Monad m => m Bool -> m ()
- ifM :: Monad m => m Bool -> m a -> m a -> m a
- notM :: Functor m => m Bool -> m Bool
- (||^) :: Monad m => m Bool -> m Bool -> m Bool
- (&&^) :: Monad m => m Bool -> m Bool -> m Bool
- orM :: Monad m => [m Bool] -> m Bool
- andM :: Monad m => [m Bool] -> m Bool
- anyM :: Monad m => (a -> m Bool) -> [a] -> m Bool
- allM :: Monad m => (a -> m Bool) -> [a] -> m Bool
- findM :: Monad m => (a -> m Bool) -> [a] -> m (Maybe a)
- firstJustM :: Monad m => (a -> m (Maybe b)) -> [a] -> m (Maybe b)
- isLeft :: Either t t1 -> Bool
- isRight :: Either t t1 -> Bool
- fromLeft :: Either t t1 -> t
- fromRight :: Either t t1 -> t1
- fromEither :: Either a a -> a
- modifyIORef' :: IORef a -> (a -> a) -> IO ()
- writeIORef' :: IORef a -> a -> IO ()
- atomicModifyIORef' :: IORef a -> (a -> (a, b)) -> IO b
- atomicWriteIORef :: IORef a -> a -> IO ()
- atomicWriteIORef' :: IORef a -> a -> IO ()
- lower :: String -> String
- upper :: String -> String
- strip :: String -> String
- stripStart :: String -> String
- stripEnd :: String -> String
- dropAround :: (a -> Bool) -> [a] -> [a]
- word1 :: String -> (String, String)
- drop1 :: [a] -> [a]
- list :: b -> (a -> [a] -> b) -> [a] -> b
- uncons :: [a] -> Maybe (a, [a])
- unsnoc :: [a] -> Maybe ([a], a)
- cons :: a -> [a] -> [a]
- snoc :: [a] -> a -> [a]
- groupSort :: Ord k => [(k, v)] -> [(k, [v])]
- groupSortOn :: Ord a => (k -> a) -> [(k, v)] -> [(k, [v])]
- nubOn :: Eq b => (a -> b) -> [a] -> [a]
- groupOn :: Eq b => (a -> b) -> [a] -> [[a]]
- sortOn :: Ord b => (a -> b) -> [a] -> [a]
- chop :: ([a] -> (b, [a])) -> [a] -> [b]
- for :: [a] -> (a -> b) -> [b]
- rep :: Eq a => a -> a -> a -> a
- reps :: Eq a => a -> a -> [a] -> [a]
- disjoint :: Eq a => [a] -> [a] -> Bool
- distinct :: Eq a => [a] -> Bool
- dropEnd :: Int -> [a] -> [a]
- takeEnd :: Int -> [a] -> [a]
- breakEnd :: (a -> Bool) -> [a] -> ([a], [a])
- spanEnd :: (a -> Bool) -> [a] -> ([a], [a])
- dropWhileEnd :: (a -> Bool) -> [a] -> [a]
- takeWhileEnd :: (a -> Bool) -> [a] -> [a]
- stripSuffix :: Eq a => [a] -> [a] -> Maybe [a]
- concatUnzip :: [([a], [b])] -> ([a], [b])
- merge :: Ord a => [a] -> [a] -> [a]
- mergeBy :: (a -> a -> Ordering) -> [a] -> [a] -> [a]
- replace :: String -> String -> String -> String
- wordsBy :: (a -> Bool) -> [a] -> [[a]]
- linesBy :: (a -> Bool) -> [a] -> [[a]]
- firstJust :: (a -> Maybe b) -> [a] -> Maybe b
- breakOn :: Eq a => [a] -> [a] -> ([a], [a])
- breakOnEnd :: Eq a => [a] -> [a] -> ([a], [a])
- splitOn :: Eq a => [a] -> [a] -> [[a]]
- split :: (a -> Bool) -> [a] -> [[a]]
- chunksOf :: Int -> [a] -> [[a]]
- dupe :: a -> (a, a)
- fst3 :: (a, b, c) -> a
- snd3 :: (a, b, c) -> b
- thd3 :: (a, b, c) -> c
- concat2 :: [([a], [b])] -> ([a], [b])
- concat3 :: [([a], [b], [c])] -> ([a], [b], [c])
- showDP :: RealFloat a => Int -> a -> String
- intToDouble :: Int -> Double
- intToFloat :: Int -> Float
- floatToDouble :: Float -> Double
- doubleToFloat :: Double -> Float
- withCurrentDirectory :: FilePath -> IO a -> IO a
- getDirectoryContentsRecursive :: FilePath -> IO [FilePath]
- getExecutablePath :: IO FilePath
- lookupEnv :: String -> IO (Maybe String)
- isWindows :: Bool
- getProcessorCount :: IO Int
- readFileEncoding :: TextEncoding -> FilePath -> IO String
- readFileUTF8 :: FilePath -> IO String
- readFileBinary :: FilePath -> IO String
- readFile' :: FilePath -> IO String
- readFileEncoding' :: TextEncoding -> FilePath -> IO String
- readFileUTF8' :: FilePath -> IO String
- readFileBinary' :: FilePath -> IO String
- writeFileEncoding :: TextEncoding -> FilePath -> String -> IO ()
- writeFileUTF8 :: FilePath -> String -> IO ()
- writeFileBinary :: FilePath -> String -> IO ()
- withTempFile :: (FilePath -> IO a) -> IO a
- withTempDir :: (FilePath -> IO a) -> IO a
- captureOutput :: IO () -> IO String
- withBuffering :: Handle -> BufferMode -> IO a -> IO a
- sleep :: Double -> IO ()
- subtractTime :: UTCTime -> UTCTime -> Double
- showTime :: Double -> String
- offsetTime :: IO (IO Double)
- offsetTimeIncrease :: IO (IO Double)
- duration :: IO a -> IO (Double, a)
Control.Concurrent.Extra
withNumCapabilities :: Int -> IO a -> IO aSource
On GHC 7.6 and above with the -threaded
flag, brackets a call to setNumCapabilities
.
On lower versions (which lack setNumCapabilities
) this function just runs the argument action.
setNumCapabilities :: Int -> IO ()Source
A version of setNumCapabilities
that works on all versions of GHC, but has no effect before GHC 7.6.
Control.Exception.Extra
showException :: SomeException -> IO StringSource
Print an exception, but if that exception itself contains exceptions, simply print
<NestedException>
. Since Haskell is a lazy language it is possible to throw
exceptions that are themselves undefined. This function is useful to report them to users.
catchJust_ :: (SomeException -> Maybe b) -> IO a -> (b -> IO a) -> IO aSource
handleJust_ :: (SomeException -> Maybe b) -> (b -> IO a) -> IO a -> IO aSource
Control.Monad.Extra
whenJust :: Applicative m => Maybe a -> (a -> m ()) -> m ()Source
partitionM :: Monad m => (a -> m Bool) -> [a] -> m ([a], [a])Source
concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b]Source
firstJustM :: Monad m => (a -> m (Maybe b)) -> [a] -> m (Maybe b)Source
Data.Either.Extra
fromEither :: Either a a -> aSource
Data.IORef.Extra
modifyIORef' :: IORef a -> (a -> a) -> IO ()
Strict version of modifyIORef
writeIORef' :: IORef a -> a -> IO ()Source
atomicModifyIORef' :: IORef a -> (a -> (a, b)) -> IO b
Strict version of atomicModifyIORef
. This forces both the value stored
in the IORef
as well as the value returned.
atomicWriteIORef :: IORef a -> a -> IO ()
Variant of writeIORef
with the "barrier to reordering" property that
atomicModifyIORef
has.
atomicWriteIORef' :: IORef a -> a -> IO ()Source
Data.List.Extra
stripStart :: String -> StringSource
dropAround :: (a -> Bool) -> [a] -> [a]Source
groupSortOn :: Ord a => (k -> a) -> [(k, v)] -> [(k, [v])]Source
dropWhileEnd :: (a -> Bool) -> [a] -> [a]
The dropWhileEnd
function drops the largest suffix of a list
in which the given predicate holds for all elements. For example:
dropWhileEnd isSpace "foo\n" == "foo" dropWhileEnd isSpace "foo bar" == "foo bar" dropWhileEnd isSpace ("foo\n" ++ undefined) == "foo" ++ undefined
takeWhileEnd :: (a -> Bool) -> [a] -> [a]Source
stripSuffix :: Eq a => [a] -> [a] -> Maybe [a]Source
Return the prefix of the second string if its suffix matches the entire first string.
Examples:
stripSuffix "bar" "foobar" == Just "foo" stripSuffix "" "baz" == Just "baz" stripSuffix "foo" "quux" == Nothing
concatUnzip :: [([a], [b])] -> ([a], [b])Source
breakOn :: Eq a => [a] -> [a] -> ([a], [a])Source
Find the first instance of needle
in haystack
.
The first element of the returned tuple
is the prefix of haystack
before needle
is matched. The second
is the remainder of haystack
, starting with the match.
Examples:
breakOn "::" "a::b::c" == ("a", "::b::c") breakOn "/" "foobar" == ("foobar", "")
Laws:
\needle haystack -> let (prefix,match) = breakOn needle haystack in prefix ++ match == haystack
breakOnEnd :: Eq a => [a] -> [a] -> ([a], [a])Source
Similar to breakOn
, but searches from the end of the
string.
The first element of the returned tuple is the prefix of haystack
up to and including the last match of needle
. The second is the
remainder of haystack
, following the match.
breakOnEnd "::" "a::b::c" == ("a::b::", "c")
splitOn :: Eq a => [a] -> [a] -> [[a]]Source
Break a list into pieces separated by the first list argument, consuming the delimiter. An empty delimiter is invalid, and will cause an error to be raised.
Examples:
splitOn "\r\n" "a\r\nb\r\nd\r\ne" == ["a","b","d","e"] splitOn "aaa" "aaaXaaaXaaaXaaa" == ["","X","X","X",""] splitOn "x" "x" == ["",""] splitOn "x" "" == [""]
and
\s x -> s /= "" ==> intercalate s (splitOn s x) == x \c x -> splitOn [c] x == split (==c) x
split :: (a -> Bool) -> [a] -> [[a]]Source
Splits a list into components delimited by separators, where the predicate returns True for a separator element. The resulting components do not contain the separators. Two adjacent separators result in an empty component in the output. eg.
split (=='a') "aabbaca" == ["","","bb","c",""] split (=='a') "" == [""]
Data.Tuple.Extra
Numeric.Extra
intToDouble :: Int -> DoubleSource
intToFloat :: Int -> FloatSource
floatToDouble :: Float -> DoubleSource
doubleToFloat :: Double -> FloatSource
System.Directory.Extra
withCurrentDirectory :: FilePath -> IO a -> IO aSource
System.Environment.Extra
getExecutablePath :: IO FilePath
Returns the absolute pathname of the current executable.
Note that for scripts and interactive sessions, this is the path to the interpreter (e.g. ghci.)
lookupEnv :: String -> IO (Maybe String)
Return the value of the environment variable var
, or Nothing
if
there is no such value.
For POSIX users, this is equivalent to getEnv
.
System.Info.Extra
System.IO.Extra
readFileEncoding :: TextEncoding -> FilePath -> IO StringSource
readFileUTF8 :: FilePath -> IO StringSource
readFileBinary :: FilePath -> IO StringSource
readFileEncoding' :: TextEncoding -> FilePath -> IO StringSource
readFileUTF8' :: FilePath -> IO StringSource
writeFileEncoding :: TextEncoding -> FilePath -> String -> IO ()Source
writeFileUTF8 :: FilePath -> String -> IO ()Source
writeFileBinary :: FilePath -> String -> IO ()Source
withTempFile :: (FilePath -> IO a) -> IO aSource
withTempDir :: (FilePath -> IO a) -> IO aSource
captureOutput :: IO () -> IO StringSource
withBuffering :: Handle -> BufferMode -> IO a -> IO aSource
System.Time.Extra
subtractTime :: UTCTime -> UTCTime -> DoubleSource
offsetTime :: IO (IO Double)Source
Call once at the start, then call repeatedly to get Time values out
offsetTimeIncrease :: IO (IO Double)Source
Like offsetTime, but results will never decrease (though they may stay the same)