]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki/Interpreter.hs
fix design problem
[Rakka.git] / Rakka / Wiki / Interpreter.hs
1 module Rakka.Wiki.Interpreter
2     ( Interpreter(..)
3     , InterpreterContext(..)
4
5     , commandName -- private
6     , commandType -- private
7     )
8     where
9
10 import           Rakka.Page
11 import           Rakka.Storage
12 import           Rakka.SystemConfig
13 import           Rakka.Wiki
14 import           Text.XML.HXT.DOM.TypeDefs
15
16
17 data Interpreter
18     = InlineCommandInterpreter {
19         iciName      :: !String
20       , iciInterpret :: !(InterpreterContext -> InlineCommand -> IO InlineElement)
21       }
22     | BlockCommandInterpreter {
23         bciName      :: !String
24       , bciInterpret :: !(InterpreterContext -> BlockCommand -> IO BlockElement)
25       }
26
27
28 data InterpreterContext
29     = InterpreterContext {
30         ctxPageName   :: !(Maybe PageName)
31       , ctxMainPage   :: !(Maybe XmlTree)
32       , ctxMainWiki   :: !(Maybe WikiPage)
33       , ctxTargetWiki :: !WikiPage
34       , ctxStorage    :: !Storage
35       , ctxSysConf    :: !SystemConfig
36       }
37
38
39 commandName :: Interpreter -> String
40 commandName (InlineCommandInterpreter name _) = name
41 commandName (BlockCommandInterpreter  name _) = name
42
43
44 commandType :: Interpreter -> CommandType
45 commandType (InlineCommandInterpreter _ _) = InlineCommandType
46 commandType (BlockCommandInterpreter  _ _) = BlockCommandType