Created
July 24, 2010 19:05
-
-
Save gregorycollins/488893 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE EmptyDataDecls #-} | |
{-# LANGUAGE PackageImports #-} | |
module Snaplets where | |
import "monads-fd" Control.Monad.State | |
import Data.ByteString (ByteString) | |
import Data.Dynamic | |
import Data.Map (Map) | |
import Snap.Types | |
------------------------------------------------------------------------------ | |
-- snaplet object brokerage | |
data SnapletBroker | |
------------------------------------------------------------------------------ | |
require :: (Typeable a) => | |
SnapletBroker -- ^ object broker | |
-> ByteString -- ^ id of resource, e.g. \"com.snapframework.user\" | |
-> Maybe a | |
require = undefined | |
------------------------------------------------------------------------------ | |
register :: (Typeable a) => | |
SnapletBroker -- ^ object broker | |
-> ByteString -- ^ id of snaplet | |
-> [ByteString] -- ^ ids of resources exported | |
-> a -- ^ object | |
-> SnapletBroker | |
register = undefined | |
------------------------------------------------------------------------------ | |
data SnapletConfig = SnapletConfig | |
{ mountPoint :: ByteString | |
, dataDirectory :: FilePath | |
, snapletId :: ByteString | |
, broker :: SnapletBroker | |
, configuration :: Map ByteString ByteString } | |
------------------------------------------------------------------------------ | |
data SnapletState snaplet | |
------------------------------------------------------------------------------ | |
class (Typeable a) => SnapletClass a where | |
initialize :: SnapletConfig -> IO a | |
destroy :: a -> IO () | |
reload :: a -> IO a | |
getHandler :: a -> Maybe (Snap ()) | |
setupDirectoryWithDefaultSettings :: FilePath -> IO a | |
provides :: a -> [ByteString] | |
depends :: a -> [ByteString] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment