module Network.MoHWS.Module.Description where
import qualified Network.MoHWS.Module as Module
import qualified Network.MoHWS.Configuration.Parser as ConfigParser
import qualified Network.MoHWS.Server.Context as ServerContext
import qualified Data.Accessor.Basic as Accessor
data T body ext = Cons
{
T body ext -> String
name :: String,
T body ext -> T ext -> IO (T body)
load :: ServerContext.T ext -> IO (Module.T body),
T body ext -> T () ext
configParser :: ConfigParser.T () ext,
T body ext -> ext -> ext
setDefltConfig :: ext -> ext
}
empty :: T body ext
empty :: T body ext
empty = Cons :: forall body ext.
String
-> (T ext -> IO (T body)) -> T () ext -> (ext -> ext) -> T body ext
Cons
{
name :: String
name = String
"<unnamed module>",
load :: T ext -> IO (T body)
load = IO (T body) -> T ext -> IO (T body)
forall a b. a -> b -> a
const (IO (T body) -> T ext -> IO (T body))
-> IO (T body) -> T ext -> IO (T body)
forall a b. (a -> b) -> a -> b
$ T body -> IO (T body)
forall (m :: * -> *) a. Monad m => a -> m a
return T body
forall body. T body
Module.empty,
configParser :: T () ext
configParser = String -> T () ext
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"no parser available",
setDefltConfig :: ext -> ext
setDefltConfig = ext -> ext
forall a. a -> a
id
}
lift :: Accessor.T fullExt partExt -> T body partExt -> T body fullExt
lift :: T fullExt partExt -> T body partExt -> T body fullExt
lift T fullExt partExt
acc T body partExt
desc = Cons :: forall body ext.
String
-> (T ext -> IO (T body)) -> T () ext -> (ext -> ext) -> T body ext
Cons
{
name :: String
name = T body partExt -> String
forall body ext. T body ext -> String
name T body partExt
desc,
load :: T fullExt -> IO (T body)
load = T body partExt -> T partExt -> IO (T body)
forall body ext. T body ext -> T ext -> IO (T body)
load T body partExt
desc (T partExt -> IO (T body))
-> (T fullExt -> T partExt) -> T fullExt -> IO (T body)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (fullExt -> partExt) -> T fullExt -> T partExt
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (T fullExt partExt -> fullExt -> partExt
forall r a. T r a -> r -> a
Accessor.get T fullExt partExt
acc),
configParser :: T () fullExt
configParser = T fullExt partExt -> T () partExt -> T () fullExt
forall fullExt partExt st.
T fullExt partExt -> T st partExt -> T st fullExt
ConfigParser.lift T fullExt partExt
acc (T () partExt -> T () fullExt) -> T () partExt -> T () fullExt
forall a b. (a -> b) -> a -> b
$ T body partExt -> T () partExt
forall body ext. T body ext -> T () ext
configParser T body partExt
desc,
setDefltConfig :: fullExt -> fullExt
setDefltConfig = T fullExt partExt -> (partExt -> partExt) -> fullExt -> fullExt
forall r a. T r a -> (a -> a) -> r -> r
Accessor.modify T fullExt partExt
acc (T body partExt -> partExt -> partExt
forall body ext. T body ext -> ext -> ext
setDefltConfig T body partExt
desc)
}