-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Web framework -- -- Miscellaneous utilities for Happstack packages. @package happstack-util @version 6.0.3 module Happstack.Util.FileManip -- | Unconditionally return True. always :: FindClause Bool -- | Search a directory recursively, with recursion controlled by a -- RecursionPredicate. Lazily return a sorted list of all files -- matching the given FilterPredicate. Any errors that occur are -- ignored, with warnings printed to stderr. find :: RecursionPredicate -> FilterPredicate -> FilePath -> IO [FilePath] instance Eq FileInfo instance Functor FindClause instance Monad FindClause instance Eq FileStatus module Happstack.Util.TH -- | Version of instanceD that takes in a Q [Dec] instead of a [Q -- Dec] and filters out signatures from the list of declarations instanceD' :: CxtQ -> TypeQ -> Q [Dec] -> DecQ -- | Returns true if the Dec matches a SigD constructor isSigD :: Dec -> Bool -- | Cross platform way to open a file exclusively module Happstack.Util.OpenExclusively openExclusively :: FilePath -> IO Handle module Happstack.Util.LogFormat -- | Format the time as describe in the Apache combined log format. -- http:httpd.apache.orgdocs2.2/logs.html#combined -- -- The format is: [daymonthyear:hour:minute:second zone] day = -- 2*digit month = 3*letter year = 4*digit hour = 2*digit minute = -- 2*digit second = 2*digit zone = (+ | -) 4*digit formatTimeCombined :: FormatTime t => t -> String -- | Format the request as describe in the Apache combined log format. -- http:httpd.apache.orgdocs2.2/logs.html#combined -- -- The format is: %h - %u %t "%r" %>s %b "%{Referer}i" -- "%{User-agent}i" %h: This is the IP address of the client (remote -- host) which made the request to the server. %u: This is the userid of -- the person requesting the document as determined by HTTP -- authentication. %t: The time that the request was received. %r: The -- request line from the client is given in double quotes. %>s: This -- is the status code that the server sends back to the client. %b: The -- last part indicates the size of the object returned to the client, not -- including the response headers. %{Referer}: The Referer (sic) -- HTTP request header. %{User-agent}: The User-Agent HTTP request -- header. formatRequestCombined :: FormatTime t => String -> String -> t -> String -> Int -> Integer -> String -> String -> String module Happstack.Util.HostAddress -- | Converts a HostAddress to a String in dot-decimal notation showHostAddress :: HostAddress -> String -- | Converts a IPv6 HostAddress6 to standard hex notation showHostAddress6 :: HostAddress6 -> String type HostAddress = Word32 type HostAddress6 = (Word32, Word32, Word32, Word32) module Happstack.Util.Cron -- | Given an action f and a number of seconds t, cron will execute f every -- t seconds with the first execution t seconds after cron is called. -- cron does not spawn a new thread. cron :: Seconds -> IO () -> IO a module Happstack.Util.Concurrent -- | Equivalent to a composition of fork and foreverSt forkEverSt :: (t -> IO t) -> t -> IO ThreadId -- | Similar to forever but with an explicit state parameter threaded -- through the computation. foreverSt :: Monad m => (t -> m t) -> t -> m b -- | Equivalent to a composition of fork and forever forkEver :: IO a -> IO ThreadId -- | Lifts the argument with Right before writing it into the chan writeChanRight :: Chan (Either a b) -> b -> IO () -- | Lifts the argument with Left before writing it into the chan writeChanLeft :: Chan (Either a b) -> a -> IO () -- | Fork that throws away the ThreadId fork_ :: IO a -> IO () -- | Fork a new thread. fork :: IO a -> IO ThreadId -- | Register an action to be run when ghci is restarted. registerResetAction :: IO () -> IO () -- | Reset state reset :: IO () -- | A version of forever that will gracefully catch IO exceptions and -- continue executing the provided action. forever :: IO a -> IO a -- | Sleep N seconds sleep :: Int -> IO () -- | Various helper routines. module Happstack.Util.Common type Seconds = Int type EpochSeconds = Int64 epochSeconds :: CalendarTime -> EpochSeconds eSecsToCalTime :: EpochSeconds -> IO CalendarTime epochPico :: CalendarTime -> Integer logMC :: Priority -> String -> IO () -- | Put a line into a handle followed by rn and echo to stdout hPutLine :: Handle -> String -> IO () -- | Get a line from the handle and echo to stdout hGetLn :: Handle -> IO String unBracket, trim, rtrim, ltrim :: String -> String -- | 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 splitList :: Eq a => a -> [a] -> [[a]] -- | Repeatedly splits a list and collects the results splitListBy :: (a -> Bool) -> [a] -> [[a]] -- | Split is like break, but the matching element is dropped. split :: (a -> Bool) -> [a] -> ([a], [a]) -- | Read file with a default value if the file does not exist. mbReadFile :: a -> (String -> a) -> FilePath -> IO a mapFst :: (a -> b) -> [(a, x)] -> [(b, x)] mapSnd :: (a -> b) -> [(x, a)] -> [(x, b)] -- | applies the list of functions to the provided argument revmap :: a -> [a -> b] -> [b] -- | comp f a b compares a and b after apply -- f. comp :: Ord t => (a -> t) -> a -> a -> Ordering -- | Run an external command. Upon failure print status to stderr. runCommand :: String -> [String] -> IO () -- | Unsafe tracing, outputs the message and the value to stderr. debug :: Show a => String -> a -> a -- | Unsafe tracing messages inside a monad. debugM :: Monad m => String -> m () -- | Read in any monad. readM :: (Monad m, Read t) => String -> m t -- | Convert Maybe into an another monad. This is a simple injection that -- calls fail when given a Nothing. maybeM :: Monad m => Maybe a -> m a -- | Lifts a bool into a MonadPlus, with False mapped to the mzero. boolM :: MonadPlus m => Bool -> m Bool -- | notMb a b returns Just a if b is -- Nothing and Nothing if b is Just -- _. notMb :: a -> Maybe a -> Maybe a -- | 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. periodic :: [Int] -> IO () -> IO ThreadId (.^) :: Int -> Int -> Int -- | Similar to periodic but runs in the same thread periodic' :: [Int] -> IO a -> IO a -- | Compatiblity for ByteStrings module Happstack.Util.ByteStringCompat -- | Semantically equivalent to break on strings breakChar :: Char -> ByteString -> (ByteString, ByteString) -- | breakCharEnd behaves like breakChar, but from the end of the -- ByteString. -- --
-- breakCharEnd ('b') (pack "aabbcc") == ("aab","cc")
--
--
-- and the following are equivalent:
--
-- -- breakCharEnd 'c' "abcdef" -- let (x,y) = break (=='c') (reverse "abcdef") -- in (reverse (drop 1 y), reverse x) --breakCharEnd :: Char -> ByteString -> (ByteString, ByteString) -- | Drops leading spaces in the ByteString dropSpace :: ByteString -> ByteString -- | Drops trailing spaces in the ByteString dropSpaceEnd :: ByteString -> ByteString -- | Chunk a lazy bytestring into reasonable chunks - is id from outside. -- This is useful to make bytestring chunks reasonable sized for e.g. -- compression. rechunkLazy :: ByteString -> ByteString module Happstack.Util.AutoBuild -- | Functionality for the autoBuild tool. Inspired by searchpath. autoBuild :: String -> String -> [String] -> IO () module Happstack.Crypto.MD5 -- | Will read the lazy ByteString and return the md5 digest. Some -- application might want to wrap this function for type safty. md5 :: ByteString -> ByteString md5InitialContext :: MD5Context md5Update :: MD5Context -> ByteString -> MD5Context md5Finalize :: MD5Context -> ByteString data MD5Context md5File :: String -> IO () stringMD5 :: ByteString -> String applyMD5Rounds :: MD5Partial -> ByteString -> MD5Partial test :: IO () module Happstack.Crypto.SHA1 sha1 :: String -> String sha1Raw :: String -> String sha1_size :: Integral a => a -> String -> String module Happstack.Util.Daemonize daemonize :: FilePath -> IO a -> IO a getDaemonizedId :: IO String module Happstack.Crypto.DES des_enc :: Message -> Key -> Enc des_dec :: Message -> Key -> Enc type Message = Zord64 type Enc = Zord64 instance Eq Zord64 instance Ord Zord64 instance Bounded Zord64 instance Bits [Bool] instance Num [Bool] instance Enum Zord64 instance Real Zord64 instance Integral Zord64 instance Bits Zord64 instance Num Zord64 instance Read Zord64 instance Show Zord64 module Happstack.Crypto.W64 pad :: String -> String unpad :: Enum a => [a] -> [a] prop_PadUnPad :: String -> Bool is4Char :: [a] -> Bool quadCharToW64 :: (Num b, Enum a) => [a] -> b w64ToQuadChar :: (Integral a, Enum b) => a -> [b] w64ToQuadNum :: Integral a => a -> [a] toQuadChars :: [a] -> [[a]] stringToW64s :: Num a => String -> [a] w64sToString :: Enum b => [Integer] -> [b] prop_stringW64 :: String -> Bool hexToW64 :: Num a => String -> a stringToKey :: Num a => String -> a des_encrypt :: String -> String -> [Enc] des_decrypt :: Enum a => String -> [Message] -> [a] prop_DES :: String -> String -> Bool module Happstack.Crypto.Base64 encode, decode :: String -> String -- | Cut up a string into 72 char lines, each line terminated by CRLF. chop72 :: String -> String module Happstack.Crypto.HMAC hmacSHA1 :: String -> String -> String