-- 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.1


-- | 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.Exception Network.NineP.Error.NineError
instance GHC.Show.Show Network.NineP.Error.NineError


-- | Provides one with the ability to pass her own monads in the callbacks.
module Control.Monad.EmbedIO

-- | <a>MonadIO</a>s that can be collapsed to and restored from a distinct
--   value.
class (MonadIO o) => EmbedIO o where type Content o where {
    type family Content o;
}

-- | Propagate an <a>IO</a> 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 <a>IO</a> monad.
data Void

-- | <a>bracket</a> equivalent.
bracketE :: EmbedIO m => m r -> (r -> m b) -> (r -> m a) -> m a

-- | <a>catch</a> equivalent.
catchE :: (EmbedIO m, Exception e) => m a -> (e -> m a) -> m a

-- | <a>handle</a> equivalent.
handleE :: (EmbedIO m, Exception e) => (e -> m a) -> m a -> m a

-- | <a>try</a> equivalent.
tryE :: (EmbedIO m, Exception e) => m a -> m (Either e a)

-- | <a>throw</a> equivalent.
throwE :: (EmbedIO m, Exception e) => e -> m a

-- | <a>forkIO</a> equivalent.
forkE :: EmbedIO m => m () -> m ThreadId
instance Control.Monad.EmbedIO.EmbedIO GHC.Types.IO


-- | 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 <a>Ref</a>
--   instances, with converstion to the appropriate types. See
--   <a>Instances</a>, <a>Instances</a> and <a>Instances</a>. 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 <a>simpleFile</a>.
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 <a>IORef</a>
--   <a>ByteString</a>
memoryFile :: forall m. (Monad m, EmbedIO m) => String -> IO (NineFile m)

-- | A composition of a <a>simpleDirectory</a> and a <a>memoryFile</a>
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
--   <tt>Convertible a b</tt> instance represents an <tt>a</tt> that can be
--   converted to a <tt>b</tt>.
class Convertible a b
class ReadRef sr (m :: * -> *) a | sr -> a
class WriteRef sr (m :: * -> *) 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 <tt>.</tt>.
[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 <tt>.</tt> and <tt>..</tt> entries.
[getFiles] :: NineFile m -> m [NineFile m]
[parent] :: NineFile m -> m (Maybe (NineFile m))

-- | A callback to address a specific file by its name. <tt>.</tt> and
--   <tt>..</tt> 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 <tt>.</tt>.
[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 <a>boringFile</a>s.
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 <tt>/</tt> directory of the hosted filesystem.
[root] :: Config m -> NineFile m

-- | The listening address. The syntax is taken from <tt>Plan 9</tt>
--   operating system and has the form <tt>unix!/path/to/socket</tt> for
--   unix socket files, and <tt>tcp!hostname!port</tt> for tcp sockets.
[addr] :: Config m -> String

-- | The initial state for the user-supplied monad. Use <a>Void</a> for
--   <a>IO</a>.
[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
