module Rakka.Wiki.Interpreter
( Interpreter(..)
+ , InterpreterContext(..)
, commandName -- private
, commandType -- private
-
- , pureInlineInterp
)
where
data Interpreter
= InlineCommandInterpreter {
iciName :: String
- , iciInterpret :: InlineCommand
- -> Maybe Page
- -> Storage
- -> SystemConfig
- -> IO InlineElement
+ , iciInterpret :: InterpreterContext -> InlineCommand -> IO InlineElement
+ }
+ | BlockCommandInterpreter {
+ bciName :: String
+ , bciInterpret :: InterpreterContext -> BlockCommand -> IO BlockElement
+ }
+
+
+data InterpreterContext
+ = InterpreterContext {
+ ctxPage :: Maybe Page
+ , ctxTree :: WikiPage
+ , ctxStorage :: Storage
+ , ctxSysConf :: SystemConfig
}
commandName :: Interpreter -> String
commandName (InlineCommandInterpreter name _) = name
+commandName (BlockCommandInterpreter name _) = name
commandType :: Interpreter -> CommandType
commandType (InlineCommandInterpreter _ _) = InlineCommandType
-
-
-pureInlineInterp :: String
- -> (InlineCommand -> Maybe Page -> InlineElement)
- -> Interpreter
-pureInlineInterp name f
- = InlineCommandInterpreter name $ \ cmd page _ _ -> return $ f cmd page
+commandType (BlockCommandInterpreter _ _) = BlockCommandType