Skip to content

Instantly share code, notes, and snippets.

@gregorycollins
Created July 24, 2010 19:05
Show Gist options
  • Save gregorycollins/488893 to your computer and use it in GitHub Desktop.
Save gregorycollins/488893 to your computer and use it in GitHub Desktop.
{-# 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