]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki/Interpreter.hs
Record before an experiment
[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
15
16 data Interpreter
17     = InlineCommandInterpreter {
18         iciName      :: String
19       , iciInterpret :: InterpreterContext -> InlineCommand -> IO InlineElement
20       }
21     | BlockCommandInterpreter {
22         bciName      :: String
23       , bciInterpret :: InterpreterContext -> BlockCommand -> IO BlockElement
24       }
25
26
27 data InterpreterContext
28     = InterpreterContext {
29         ctxPage    :: Maybe Page
30       , ctxTree    :: WikiPage
31       , ctxStorage :: Storage
32       , ctxSysConf :: SystemConfig
33       }
34
35
36 commandName :: Interpreter -> String
37 commandName (InlineCommandInterpreter name _) = name
38 commandName (BlockCommandInterpreter  name _) = name
39
40
41 commandType :: Interpreter -> CommandType
42 commandType (InlineCommandInterpreter _ _) = InlineCommandType
43 commandType (BlockCommandInterpreter  _ _) = BlockCommandType