-- 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.4.6 -- | 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 { -- | Intermediate state storage type. type family Content o; } -- | Propagate an IO operation over the storage type to the monadic -- type. embed :: EmbedIO o => (Content o -> IO a) -> o a -- | Run the monadic computation using supplied state. 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 Control.Monad.EmbedIO.EmbedIO GHC.Types.IO -- | The exceptions one would want to throw to be understood by the -- existing 9P clients. module Network.NineP.Error data NineError ENotImplemented :: String -> NineError ENotADir :: NineError EDir :: NineError ENoFile :: String -> NineError ENoFid :: Word32 -> NineError ENoAuthRequired :: NineError EPermissionDenied :: NineError EInval :: NineError OtherError :: String -> NineError instance GHC.Exception.Type.Exception Network.NineP.Error.NineError instance GHC.Show.Show Network.NineP.Error.NineError -- | Higher-level file patterns. Don't support read/write operations at -- offsets and handling stat changes as for now. module Network.NineP.File -- | Tests if the file is a directory isDir :: Word32 -> Bool -- | 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 :: forall a b m rr wr. (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 :: forall a b m. (Monad m, EmbedIO m) => String -> (m a, b -> m ()) -> (a -> ByteString, ByteString -> b) -> NineFile m -- | A directory that stores its contents in the form of 'IORef [(String, -- NineFile m)]' simpleDirectory :: forall m. (Monad m, EmbedIO m) => String -> (String -> m (NineFile m)) -> (String -> m (NineFile m)) -> IO (NineFile m, IORef [(String, NineFile m)]) -- | A file that reads and writes using simple user-specified callbacks. rwFile :: forall m. EmbedIO m => String -> Maybe (m ByteString) -> Maybe (ByteString -> m ()) -> NineFile m -- | A file that stores its contents in the form of IORef -- ByteString memoryFile :: forall m. (Monad m, EmbedIO m) => String -> IO (NineFile m) -- | A composition of a simpleDirectory and a memoryFile memoryDirectory :: forall m. (Monad m, EmbedIO m) => String -> IO (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 :: Type -> Type) a | sr -> a class WriteRef sr (m :: Type -> Type) a | sr -> a instance Data.Convertible.Base.Convertible Data.ByteString.Lazy.Internal.ByteString Data.ByteString.Lazy.Internal.ByteString instance Data.Convertible.Base.Convertible () Data.ByteString.Lazy.Internal.ByteString instance Data.Convertible.Base.Convertible Data.ByteString.Lazy.Internal.ByteString () instance Data.Convertible.Base.Convertible Data.ByteString.Lazy.Internal.ByteString GHC.Types.Bool instance Data.Convertible.Base.Convertible GHC.Types.Bool Data.ByteString.Lazy.Internal.ByteString instance (GHC.Show.Show a, GHC.Num.Num a) => Data.Convertible.Base.Convertible a Data.ByteString.Lazy.Internal.ByteString instance (GHC.Read.Read a, GHC.Num.Num a, Data.Typeable.Internal.Typeable a) => Data.Convertible.Base.Convertible Data.ByteString.Lazy.Internal.ByteString a instance Data.StateRef.Types.ReadRef () m Data.ByteString.Lazy.Internal.ByteString instance GHC.Base.Monad m => Data.StateRef.Types.WriteRef () m Data.ByteString.Lazy.Internal.ByteString instance Control.Monad.IO.Class.MonadIO m => Data.StateRef.Types.ReadRef (Control.Concurrent.Chan.Chan a) m a instance Control.Monad.IO.Class.MonadIO m => Data.StateRef.Types.WriteRef (Control.Concurrent.Chan.Chan a) m a -- | Listening on sockets for the incoming requests. module Network.NineP.Server data NineFile m RegularFile :: (Word64 -> Word32 -> m ByteString) -> (Word64 -> ByteString -> m Word32) -> m () -> m Stat -> (Stat -> m ()) -> m Word32 -> NineFile m [read] :: NineFile m -> Word64 -> Word32 -> m ByteString [write] :: NineFile m -> Word64 -> ByteString -> 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 -> m (NineFile m)) -> (String -> Word32 -> 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 -> m (NineFile m) -- | Create a file under this directory. [create] :: NineFile m -> String -> Word32 -> 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. An user can create files, but they won't show up in listing -- and will essentially be boringFiles. 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