-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | High-level abstraction over 9P protocol -- -- A library providing one with a somewhat higher level interface to -- 9P2000 protocol than existing implementations. Designed to facilitate -- rapid development of synthetic filesystems. @package Network-NineP @version 0.2.0 module Network.NineP.Error -- | Throwable errors data NineError ENotImplemented :: String -> NineError ENotADir :: NineError EDir :: NineError ENoFile :: String -> NineError ENoFid :: Word32 -> NineError ENoAuthRequired :: NineError EPermissionDenied :: NineError OtherError :: String -> NineError instance Show NineError instance Error NineError -- | Provides one with the ability to pass her own monads in the callbacks. module Control.Monad.EmbedIO -- | MonadIOs that can be collapsed to and restored from a distinct -- value. class MonadIO o => EmbedIO o where type family Content o embed :: EmbedIO o => (Content o -> IO a) -> o a callback :: EmbedIO o => o a -> Content o -> IO a -- | Empty type. Used to represent state for IO monad. data Void -- | bracket equivalent. bracketE :: EmbedIO m => m r -> (r -> m b) -> (r -> m a) -> m a -- | catch equivalent. catchE :: (EmbedIO m, Exception e) => m a -> (e -> m a) -> m a -- | handle equivalent. handleE :: (EmbedIO m, Exception e) => (e -> m a) -> m a -> m a -- | try equivalent. tryE :: (EmbedIO m, Exception e) => m a -> m (Either e a) -- | throw equivalent. throwE :: (EmbedIO m, Exception e) => e -> m a -- | forkIO equivalent. forkE :: EmbedIO m => m () -> m ThreadId instance EmbedIO IO -- | Higher-level file patterns. Don't support read/write operations at -- offsets and handling stat changes as for now. module Network.NineP.File -- | A file that reads from and writes to the supplied Ref -- instances, with converstion to the appropriate types. See -- Instances, Instances and Instances. Use '()', if -- the file is meant to be read-only/write-only. simpleFile :: (Monad m, EmbedIO m, ReadRef rr m a, Convertible a ByteString, WriteRef wr m b, Convertible ByteString b) => String -> rr -> wr -> NineFile m -- | Typeclass-free version of simpleFile. simpleFileBy :: (Monad m, EmbedIO m) => String -> (m a, b -> m ()) -> (a -> ByteString, ByteString -> b) -> NineFile m -- | A file that reads and writes using simple user-specified callbacks. rwFile :: EmbedIO m => String -> Maybe (m ByteString) -> Maybe (ByteString -> m ()) -> NineFile m -- | Instances for dealing with the usual data. module Network.NineP.File.Instances -- | A typeclass that represents something that can be converted. A -- Convertible a b instance represents an a that can be -- converted to a b. class Convertible a b class ReadRef sr (m :: * -> *) a | sr -> a class WriteRef sr (m :: * -> *) a | sr -> a instance [overlap ok] MonadIO m => WriteRef (Chan a) m a instance [overlap ok] MonadIO m => ReadRef (Chan a) m a instance [overlap ok] Monad m => WriteRef () m ByteString instance [overlap ok] ReadRef () m ByteString instance [overlap ok] (Read a, Num a, Typeable a) => Convertible ByteString a instance [overlap ok] (Show a, Num a) => Convertible a ByteString instance [overlap ok] Convertible Bool ByteString instance [overlap ok] Convertible ByteString Bool instance [overlap ok] Convertible ByteString () instance [overlap ok] Convertible () ByteString instance [overlap ok] Convertible ByteString ByteString -- | Listening on sockets for the incoming requests. module Network.NineP.Server data NineFile m RegularFile :: (Word64 -> Word32 -> ErrorT NineError m (ByteString)) -> (Word64 -> ByteString -> ErrorT NineError m (Word32)) -> m () -> m Stat -> (Stat -> m ()) -> m Word32 -> NineFile m read :: NineFile m -> Word64 -> Word32 -> ErrorT NineError m (ByteString) write :: NineFile m -> Word64 -> ByteString -> ErrorT NineError m (Word32) remove :: NineFile m -> m () -- | The directory stat must return only stat for .. stat :: NineFile m -> m Stat wstat :: NineFile m -> Stat -> m () version :: NineFile m -> m Word32 Directory :: m [NineFile m] -> m (Maybe (NineFile m)) -> (String -> ErrorT NineError m (NineFile m)) -> m () -> m Stat -> (Stat -> m ()) -> m Word32 -> NineFile m -- | A callback to get the list of the files this directory contains. Must -- not contain . and .. entries. getFiles :: NineFile m -> m [NineFile m] parent :: NineFile m -> m (Maybe (NineFile m)) -- | A callback to address a specific file by its name. . and -- .. are handled in the library. descend :: NineFile m -> String -> ErrorT NineError m (NineFile m) remove :: NineFile m -> m () -- | The directory stat must return only stat for .. stat :: NineFile m -> m Stat wstat :: NineFile m -> Stat -> m () version :: NineFile m -> m Word32 -- | A dumb file that can't do anything. boringFile :: (Monad m, EmbedIO m) => String -> NineFile m -- | A dumb directory that can't do anything but provide the files it -- contains. boringDir :: (Monad m, EmbedIO m) => String -> [(String, NineFile m)] -> NineFile m -- | Server configuration. data Config m Config :: NineFile m -> String -> Content m -> Config m -- | The / directory of the hosted filesystem. root :: Config m -> NineFile m -- | The listening address. The syntax is taken from Plan 9 -- operating system and has the form unix!/path/to/socket for -- unix socket files, and tcp!hostname!port for tcp sockets. addr :: Config m -> String -- | The initial state for the user-supplied monad. Use Void for -- IO. monadState :: Config m -> Content m -- | Run the actual server using the supplied configuration. run9PServer :: EmbedIO m => Config m -> IO () -- | A library providing one with a somewhat higher level interface to -- 9P2000 protocol. Designed to facilitate rapid development of synthetic -- filesystems. module Network.NineP