]> gitweb @ CieloNegro.org - Rakka.git/blobdiff - Rakka/Wiki/Interpreter.hs
Record before an experiment
[Rakka.git] / Rakka / Wiki / Interpreter.hs
index 2abfc45e2947bad4f44627401d288bdc5c1df884..09f7414671e75c3a7a047826d7b6e8a9f49a9c6d 100644 (file)
@@ -1,10 +1,9 @@
 module Rakka.Wiki.Interpreter
     ( Interpreter(..)
+    , InterpreterContext(..)
 
     , commandName -- private
     , commandType -- private
-
-    , pureInlineInterp
     )
     where
 
@@ -17,24 +16,28 @@ import           Rakka.Wiki
 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