Safe Haskell | None |
---|
- data Text
- type String = Text
- class Monad m where
- data Maybe a
- data Bool
- ($) :: (a -> b) -> a -> b
- (.) :: (b -> c) -> (a -> b) -> a -> c
- data LogMessage
- = ProcessCreated FilePath
- | InvalidBundle FilePath SomeException
- | ProcessDidNotStart FilePath
- | ExceptionThrown Text SomeException
- | RemovingPort Int
- | UnpackingBundle FilePath FilePath
- | TerminatingApp Text
- | FinishedReloading Text
- | TerminatingOldProcess Text
- | RemovingOldFolder FilePath
- | ReceivedInotifyEvent Text
- | ProcessWaiting FilePath
- log :: LogMessage -> KIO ()
- logEx :: Q Exp
- data KIO a
- toString :: ToString a => a -> String
- map :: (a -> b) -> [a] -> [b]
- (***) :: Arrow a => forall b c b' c'. a b c -> a b' c' -> a (b, b') (c, c')
- readFileLBS :: FilePath -> KIO (Either SomeException ByteString)
- data Either a b
- either :: (a -> c) -> (b -> c) -> Either a b -> c
- data SomeException
- runKIO :: (LogMessage -> IO ()) -> KIO a -> IO a
- void :: Monad m => m a -> m ()
- liftIO :: IO a -> KIO (Either SomeException a)
- forkKIO :: KIO () -> KIO ()
- forkKIO' :: KIO () -> KIO (Either SomeException ThreadId)
- (++) :: Monoid m => m -> m -> m
- minBound :: Bounded a => a
- succ :: Enum a => a -> a
- show :: Show a => a -> Text
- when :: Monad m => Bool -> m () -> m ()
- fromText :: FromText a => Text -> a
- flip :: (a -> b -> c) -> b -> a -> c
- class Show a
- data KeterException
- toException :: Exception e => e -> SomeException
- newStdGen :: KIO StdGen
- class Default a where
- def :: a
- data Int
- (&&) :: Bool -> Bool -> Bool
- (==) :: Eq a => a -> a -> Bool
- (/=) :: Eq a => a -> a -> Bool
- (*) :: Num a => a -> a -> a
- fromIntegral :: (Integral a, Num b) => a -> b
- reverse :: [a] -> [a]
- otherwise :: Bool
- timeout :: Int -> KIO a -> KIO (Maybe a)
- threadDelay :: Int -> KIO ()
- id :: a -> a
- filter :: (a -> Bool) -> [a] -> [a]
- mapM_ :: Monad m => (a -> m b) -> [a] -> m ()
- fmap :: Functor f => forall a b. (a -> b) -> f a -> f b
- not :: Bool -> Bool
- maybe :: b -> (a -> b) -> Maybe a -> b
- (>) :: Ord a => a -> a -> Bool
- (<) :: Ord a => a -> a -> Bool
- (<=) :: Ord a => a -> a -> Bool
- (+) :: Num a => a -> a -> a
- (-) :: Num a => a -> a -> a
- getCurrentTime :: KIO UTCTime
- (</>) :: FilePath -> FilePath -> FilePath
- (<.>) :: FilePath -> Text -> FilePath
- data FilePath
- isDirectory :: FilePath -> IO Bool
- isFile :: FilePath -> IO Bool
- removeTree :: FilePath -> IO ()
- createTree :: FilePath -> IO ()
- directory :: FilePath -> FilePath
- rename :: FilePath -> FilePath -> IO ()
- basename :: FilePath -> FilePath
- toText :: FilePath -> Either Text Text
- hasExtension :: FilePath -> Text -> Bool
- listDirectory :: FilePath -> IO [FilePath]
- decodeString :: String -> FilePath
- data MVar a
- newMVar :: a -> KIO (MVar a)
- newEmptyMVar :: KIO (MVar a)
- modifyMVar :: MVar a -> (a -> KIO (a, b)) -> KIO b
- modifyMVar_ :: MVar a -> (a -> KIO a) -> KIO ()
- swapMVar :: MVar a -> a -> KIO a
- takeMVar :: MVar a -> KIO a
- putMVar :: MVar a -> a -> KIO ()
- data IORef a
- newIORef :: a -> KIO (IORef a)
- atomicModifyIORef :: IORef a -> (a -> (a, b)) -> KIO b
- data Chan a
- newChan :: KIO (Chan a)
- readChan :: Chan a -> KIO a
- writeChan :: Chan a -> a -> KIO ()
Documentation
data Text
A space efficient, packed, unboxed Unicode text type.
Eq Text | |
Data Text | |
Ord Text | |
Read Text | |
Show Text | |
Typeable Text | |
IsString Text | |
ToJSON Text | |
FromJSON Text | |
Monoid Text | |
NFData Text | |
Hashable Text | |
FromText Text | |
ToString Text | |
ToJSON v => ToJSON (HashMap Text v) | |
ToJSON v => ToJSON (Map Text v) | |
FromJSON v => FromJSON (HashMap Text v) | |
FromJSON v => FromJSON (Map Text v) |
class Monad m where
The Monad
class defines the basic operations over a monad,
a concept from a branch of mathematics known as category theory.
From the perspective of a Haskell programmer, however, it is best to
think of a monad as an abstract datatype of actions.
Haskell's do
expressions provide a convenient syntax for writing
monadic expressions.
Minimal complete definition: >>=
and return
.
Instances of Monad
should satisfy the following laws:
return a >>= k == k a m >>= return == m m >>= (\x -> k x >>= h) == (m >>= k) >>= h
Instances of both Monad
and Functor
should additionally satisfy the law:
fmap f xs == xs >>= return . f
The instances of Monad
for lists, Maybe
and IO
defined in the Prelude satisfy these laws.
(>>=) :: m a -> (a -> m b) -> m b
Sequentially compose two actions, passing any value produced by the first as an argument to the second.
(>>) :: m a -> m b -> m b
Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
return :: a -> m a
Inject a value into the monadic type.
Fail with a message. This operation is not part of the
mathematical definition of a monad, but is invoked on pattern-match
failure in a do
expression.
Monad [] | |
Monad IO | |
Monad Q | |
Monad Maybe | |
Monad Result | |
Monad Parser | |
Monad STM | |
Monad Put | |
Monad Identity | |
Monad Vector | |
Monad Id | |
Monad Box | |
Monad Stream | |
Monad KIO | |
Monad Parser | |
Monad ((->) r) | |
Monad (Either e) | |
Monad (ST s) | |
ArrowApply a => Monad (ArrowMonad a) | |
Monad m => Monad (ResourceT m) | |
Monad m => Monad (ExceptionT m) | |
Monad m => Monad (PErrorT m) | |
Monad (Partial e) | |
(Monad m, Error e) => Monad (ErrorT e m) | |
Monad m => Monad (StateT s m) | |
Monad m => Monad (Pipe l i o u m) |
data Maybe a
The Maybe
type encapsulates an optional value. A value of type
either contains a value of type Maybe
aa
(represented as
),
or it is empty (represented as Just
aNothing
). Using Maybe
is a good way to
deal with errors or exceptional cases without resorting to drastic
measures such as error
.
The Maybe
type is also a monad. It is a simple kind of error
monad, where all errors are represented by Nothing
. A richer
error monad can be built using the Either
type.
Monad Maybe | |
Functor Maybe | |
Typeable1 Maybe | |
MonadPlus Maybe | |
Applicative Maybe | |
Alternative Maybe | |
MonadBase Maybe Maybe | |
MonadBaseControl Maybe Maybe | |
Eq a => Eq (Maybe a) | |
Ord a => Ord (Maybe a) | |
Show a => Show (Maybe a) | |
Generic (Maybe a) | |
ToJSON a => ToJSON (Maybe a) | |
FromJSON a => FromJSON (Maybe a) | |
Monoid a => Monoid (Maybe a) | Lift a semigroup into |
Default (Maybe a) | |
Hashable a => Hashable (Maybe a) | |
Lift a => Lift (Maybe a) |
data Bool
($) :: (a -> b) -> a -> b
Application operator. This operator is redundant, since ordinary
application (f x)
means the same as (f
. However, $
x)$
has
low, right-associative binding precedence, so it sometimes allows
parentheses to be omitted; for example:
f $ g $ h x = f (g (h x))
It is also useful in higher-order situations, such as
,
or map
($
0) xs
.
zipWith
($
) fs xs
(.) :: (b -> c) -> (a -> b) -> a -> c
Function composition.
data LogMessage Source
log :: LogMessage -> KIO ()Source
map :: (a -> b) -> [a] -> [b]
map
f xs
is the list obtained by applying f
to each element
of xs
, i.e.,
map f [x1, x2, ..., xn] == [f x1, f x2, ..., f xn] map f [x1, x2, ...] == [f x1, f x2, ...]
(***) :: Arrow a => forall b c b' c'. a b c -> a b' c' -> a (b, b') (c, c')
Split the input between the two argument arrows and combine their output. Note that this is in general not a functor.
The default definition may be overridden with a more efficient version if desired.
data Either a b
The Either
type represents values with two possibilities: a value of
type
is either Either
a b
or Left
a
.
Right
b
The Either
type is sometimes used to represent a value which is
either correct or an error; by convention, the Left
constructor is
used to hold an error value and the Right
constructor is used to
hold a correct value (mnemonic: "right" also means "correct").
Typeable2 Either | |
Monad (Either e) | |
Functor (Either a) | |
Error e => MonadPlus (Either e) | |
Applicative (Either e) | |
Error e => Alternative (Either e) | |
MonadBase (Either e) (Either e) | |
MonadBaseControl (Either e) (Either e) | |
(Eq a, Eq b) => Eq (Either a b) | |
(Ord a, Ord b) => Ord (Either a b) | |
(Read a, Read b) => Read (Either a b) | |
(Show a, Show b) => Show (Either a b) | |
Generic (Either a b) | |
(ToJSON a, ToJSON b) => ToJSON (Either a b) | |
(FromJSON a, FromJSON b) => FromJSON (Either a b) | |
(Hashable a, Hashable b) => Hashable (Either a b) | |
(Lift a, Lift b) => Lift (Either a b) |
data SomeException
The SomeException
type is the root of the exception type hierarchy.
When an exception of type e
is thrown, behind the scenes it is
encapsulated in a SomeException
.
when :: Monad m => Bool -> m () -> m ()
Conditional execution of monadic expressions. For example,
when debug (putStr "Debugging\n")
will output the string Debugging\n
if the Boolean value debug
is True
,
and otherwise do nothing.
flip :: (a -> b -> c) -> b -> a -> c
takes its (first) two arguments in the reverse order of flip
ff
.
class Show a
Conversion of values to readable String
s.
Minimal complete definition: showsPrec
or show
.
Derived instances of Show
have the following properties, which
are compatible with derived instances of Read
:
- The result of
show
is a syntactically correct Haskell expression containing only constants, given the fixity declarations in force at the point where the type is declared. It contains only the constructor names defined in the data type, parentheses, and spaces. When labelled constructor fields are used, braces, commas, field names, and equal signs are also used. - If the constructor is defined to be an infix operator, then
showsPrec
will produce infix applications of the constructor. - the representation will be enclosed in parentheses if the
precedence of the top-level constructor in
x
is less thand
(associativity is ignored). Thus, ifd
is0
then the result is never surrounded in parentheses; ifd
is11
it is always surrounded in parentheses, unless it is an atomic expression. - If the constructor is defined using record syntax, then
show
will produce the record-syntax form, with the fields given in the same order as the original declaration.
For example, given the declarations
infixr 5 :^: data Tree a = Leaf a | Tree a :^: Tree a
the derived instance of Show
is equivalent to
instance (Show a) => Show (Tree a) where showsPrec d (Leaf m) = showParen (d > app_prec) $ showString "Leaf " . showsPrec (app_prec+1) m where app_prec = 10 showsPrec d (u :^: v) = showParen (d > up_prec) $ showsPrec (up_prec+1) u . showString " :^: " . showsPrec (up_prec+1) v where up_prec = 5
Note that right-associativity of :^:
is ignored. For example,
-
produces the stringshow
(Leaf 1 :^: Leaf 2 :^: Leaf 3)"Leaf 1 :^: (Leaf 2 :^: Leaf 3)"
.
data KeterException Source
toException :: Exception e => e -> SomeException
class Default a where
A class for types with a default value.
def :: a
The default value for this type.
Default Double | |
Default Float | |
Default Int | |
Default Int8 | |
Default Int16 | |
Default Int32 | |
Default Int64 | |
Default Integer | |
Default Ordering | |
Default Word | |
Default Word8 | |
Default Word16 | |
Default Word32 | |
Default Word64 | |
Default () | |
Default All | |
Default Any | |
Default IntSet | |
Default TimeLocale | |
Default Settings | |
Default Settings | |
Default [a] | |
Integral a => Default (Ratio a) | |
Default a => Default (IO a) | |
Default (Maybe a) | |
(Default a, RealFloat a) => Default (Complex a) | |
Default a => Default (Dual a) | |
Default (Endo a) | |
Num a => Default (Sum a) | |
Num a => Default (Product a) | |
Default (First a) | |
Default (Last a) | |
Default a => Default (Tree a) | |
Default (Seq a) | |
Default (IntMap v) | |
Default (Set v) | |
Default (DList a) | |
Default r => Default (e -> r) | |
(Default a, Default b) => Default (a, b) | |
Default (Map k v) | |
(Default a, Default b, Default c) => Default (a, b, c) | |
(Default a, Default b, Default c, Default d) => Default (a, b, c, d) | |
(Default a, Default b, Default c, Default d, Default e) => Default (a, b, c, d, e) |
data Int
fromIntegral :: (Integral a, Num b) => a -> b
general coercion from integral types
threadDelay :: Int -> KIO ()Source
id :: a -> a
Identity function.
filter :: (a -> Bool) -> [a] -> [a]
filter
, applied to a predicate and a list, returns the list of
those elements that satisfy the predicate; i.e.,
filter p xs = [ x | x <- xs, p x]
Filepath
(<.>) :: FilePath -> Text -> FilePath
An alias for addExtension
.
data FilePath
isDirectory :: FilePath -> IO Bool
Check if a directory exists at the given path.
Symbolic links are resolved to their targets before checking their type.
This computation does not throw exceptions.
Check if a file exists at the given path.
Any non‐directory object, including devices and pipes, are considered to be files. Symbolic links are resolved to their targets before checking their type.
This computation does not throw exceptions.
removeTree :: FilePath -> IO ()
Recursively remove a directory tree rooted at the given path.
This computation does not follow symlinks. If the tree contains symlinks, the links themselves will be removed, but not the objects they point to.
If the root path is a symlink, then it will be treated as if it were a regular directory.
This computation throws IOError
on failure. See “Classifying
I/O errors” in the System.IO.Error documentation for information on
why the failure occured.
createTree :: FilePath -> IO ()
Create a directory at a given path, including any parents which might be missing.
This computation throws IOError
on failure. See “Classifying
I/O errors” in the System.IO.Error documentation for information on
why the failure occured.
directory :: FilePath -> FilePath
Retrieves the FilePath
’s directory. If the path is already a
directory, it is returned unchanged.
rename :: FilePath -> FilePath -> IO ()
Rename a filesystem object.
This computation throws IOError
on failure. See “Classifying
I/O errors” in the System.IO.Error documentation for information on
why the failure occured.
basename :: FilePath -> FilePath
Retrieve a FilePath
’s basename component.
basename "foo/bar.txt" == "bar"
toText :: FilePath -> Either Text Text
Attempt to convert a FilePath
to human‐readable text.
If the path is decoded successfully, the result is a Right
containing
the decoded text. Successfully decoded text can be converted back to the
original path using fromText
.
If the path cannot be decoded, the result is a Left
containing an
approximation of the original path. If displayed to the user, this value
should be accompanied by some warning that the path has an invalid
encoding. Approximated text cannot be converted back to the original path.
This function ignores the user’s locale, and assumes all file paths
are encoded in UTF8. If you need to display file paths with an unusual or
obscure encoding, use encode
and then decode them manually.
Since: 0.2
hasExtension :: FilePath -> Text -> Bool
Get whether a FilePath
’s last extension is the predicate.
listDirectory :: FilePath -> IO [FilePath]
List objects in a directory, excluding "."
and ".."
. Each
returned FilePath
includes the path of the directory. Entries are not
sorted.
This computation throws IOError
on failure. See “Classifying
I/O errors” in the System.IO.Error documentation for information on
why the failure occured.
decodeString :: String -> FilePath
MVar
data MVar a
An MVar
(pronounced "em-var") is a synchronising variable, used
for communication between concurrent threads. It can be thought of
as a a box, which may be empty or full.
newEmptyMVar :: KIO (MVar a)Source
modifyMVar :: MVar a -> (a -> KIO (a, b)) -> KIO bSource
IORef
atomicModifyIORef :: IORef a -> (a -> (a, b)) -> KIO bSource