Copyright | (c) Kai Lindholm, 2014 |
---|---|
License | MIT |
Maintainer | megantti@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Action
is a command acting on various kinds of objects:
- torrents (
TorrentAction
) - files (
FileAction
) - peers (
PeerAction
) - trackers (
TrackerAction
).
They all have the property that they can be executed on a single object or on a group of objects.
For example,
callRTorrent "localhost" 5000 $ some_action (some_id :: SomeId)
is a valid thing to write when some
is one of the previous objects.
To call an action on all torrents, you can use allTorrents
, so that
callRTorrent "localhost" 5000 $ allTorrents getTorrentId
will return a list of torrent ids.
To call a action on other types of objects, you can use allPeers
,
allFiles
, or allTrackers
,
which will act on all peers, files, or trackers that are associated to a torrent.
They will also return ids for each object.
Then for example
allFiles getFileSizeBytes :: TorrentId -> TorrentAction [FileId :*: Int]
is an action that will return a list of ids and file sizes when run on a torrent.
These can further be used with allTorrents
.
To combine actions, you can use <+>
and sequenceActions
which correspond to :*:
and []
for commands.
In order to write new actions, simpleAction
can be used.
- data Action i a
- simpleAction :: XmlRpcType a => String -> [Param] -> i -> Action i a
- pureAction :: a -> i -> Action i a
- sequenceActions :: Traversable f => f (i -> Action i a) -> i -> Action i (f a)
- (<+>) :: (i -> Action i a) -> (i -> Action i b) -> i -> Action i (a :*: b)
- data Param
- newtype ActionB i a = ActionB {
- runActionB :: i -> Action i a
Documentation
A type for actions that can act on different things like torrents and files.
a
is the return type.
simpleAction :: XmlRpcType a => String -> [Param] -> i -> Action i a Source
A simple action that can be used when constructing new ones.
Watch out for using Bool
as a
since using it with this function will probably result in an error,
since RTorrent actually returns 0 or 1 instead of a bool.
One workaround is to get an Int
and use Bool
's Enum
instance.
pureAction :: a -> i -> Action i a Source
An action that does nothing but return the value.
sequenceActions :: Traversable f => f (i -> Action i a) -> i -> Action i (f a) Source
Sequence multiple actions, for example with f = []
.
(<+>) :: (i -> Action i a) -> (i -> Action i b) -> i -> Action i (a :*: b) infixr 6 Source
Combine two actions to get a new one.
Parameters for actions.