happstack-util-0.4.1: Web frameworkSource codeContentsIndex
Happstack.Util.Common
Description
Various helper routines.
Synopsis
type Seconds = Int
type EpochSeconds = Int64
epochSeconds :: CalendarTime -> EpochSeconds
eSecsToCalTime :: EpochSeconds -> IO CalendarTime
epochPico :: CalendarTime -> Integer
logMC :: Priority -> String -> IO ()
hPutLine :: Handle -> String -> IO ()
hGetLn :: Handle -> IO String
ltrim :: String -> String
rtrim :: String -> String
trim :: String -> String
unBracket :: String -> String
splitList :: Eq a => a -> [a] -> [[a]]
splitListBy :: (a -> Bool) -> [a] -> [[a]]
split :: (a -> Bool) -> [a] -> ([a], [a])
mbReadFile :: a -> (String -> a) -> FilePath -> IO a
mapFst :: (a -> b) -> [(a, x)] -> [(b, x)]
mapSnd :: (a -> b) -> [(x, a)] -> [(x, b)]
revmap :: a -> [a -> b] -> [b]
comp :: Ord t => (a -> t) -> a -> a -> Ordering
runCommand :: String -> [String] -> IO ()
debug :: Show a => String -> a -> a
debugM :: Monad m => String -> m ()
readM :: (Monad m, Read t) => String -> m t
maybeM :: Monad m => Maybe a -> m a
boolM :: MonadPlus m => Bool -> m Bool
notMb :: a -> Maybe a -> Maybe a
periodic :: [Int] -> IO () -> IO ThreadId
(.^) :: Int -> Int -> Int
periodic' :: [Int] -> IO a -> IO a
Documentation
type Seconds = IntSource
type EpochSeconds = Int64Source
epochSeconds :: CalendarTime -> EpochSecondsSource
eSecsToCalTime :: EpochSeconds -> IO CalendarTimeSource
epochPico :: CalendarTime -> IntegerSource
logMC :: Priority -> String -> IO ()Source
hPutLine :: Handle -> String -> IO ()Source
Put a line into a handle followed by rn and echo to stdout
hGetLn :: Handle -> IO StringSource
Get a line from the handle and echo to stdout
ltrim :: String -> StringSource
rtrim :: String -> StringSource
trim :: String -> StringSource
unBracket :: String -> StringSource
splitList :: Eq a => a -> [a] -> [[a]]Source

Removes the whitespace surrounding a string as well as the first and last character. unBracket (asdf) = asdf

Drops the whitespace at the start of the string

Drops the whitespace at the end of the string

Trims the beginning and ending whitespace of a string

Repeadly splits a list by the provided separator and collects the results

splitListBy :: (a -> Bool) -> [a] -> [[a]]Source
Repeatedly splits a list and collects the results
split :: (a -> Bool) -> [a] -> ([a], [a])Source
Split is like break, but the matching element is dropped.
mbReadFile :: a -> (String -> a) -> FilePath -> IO aSource
Read file with a default value if the file does not exist.
mapFst :: (a -> b) -> [(a, x)] -> [(b, x)]Source
mapSnd :: (a -> b) -> [(x, a)] -> [(x, b)]Source
revmap :: a -> [a -> b] -> [b]Source
applies the list of functions to the provided argument
comp :: Ord t => (a -> t) -> a -> a -> OrderingSource
comp f a b compares a and b after apply f.
runCommand :: String -> [String] -> IO ()Source
Run an external command. Upon failure print status to stderr.
debug :: Show a => String -> a -> aSource
Unsafe tracing, outputs the message and the value to stderr.
debugM :: Monad m => String -> m ()Source
Unsafe tracing messages inside a monad.
readM :: (Monad m, Read t) => String -> m tSource
Read in any monad.
maybeM :: Monad m => Maybe a -> m aSource
Convert Maybe into an another monad. This is a simple injection that calls fail when given a Nothing.
boolM :: MonadPlus m => Bool -> m BoolSource
Lifts a bool into a MonadPlus, with False mapped to the mzero.
notMb :: a -> Maybe a -> Maybe aSource
notMb a b returns Just a if b is Nothing and Nothing if b is Just _.
periodic :: [Int] -> IO () -> IO ThreadIdSource
Takes a list of delays, in seconds, and an action to execute repeatedly. The action is then executed repeatedly in a separate thread until the list has been consumed. The first action takes place immediately.
(.^) :: Int -> Int -> IntSource
periodic' :: [Int] -> IO a -> IO aSource
Similar to periodic but runs in the same thread
Produced by Haddock version 2.5.0