X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=Rakka.git;a=blobdiff_plain;f=Rakka%2FWiki%2FInterpreter.hs;h=09f7414671e75c3a7a047826d7b6e8a9f49a9c6d;hp=bfaab67b0cd742d2ea0f02b7ebaf7b0913fffa9a;hb=4608e8de5f9d72f12055494467283b4dea2faeb5;hpb=7c3065043cdfbd96539a9bf6bff9b1d4281c0b2a diff --git a/Rakka/Wiki/Interpreter.hs b/Rakka/Wiki/Interpreter.hs index bfaab67..09f7414 100644 --- a/Rakka/Wiki/Interpreter.hs +++ b/Rakka/Wiki/Interpreter.hs @@ -1,11 +1,9 @@ module Rakka.Wiki.Interpreter ( Interpreter(..) + , InterpreterContext(..) , commandName -- private , commandType -- private - - , pureInlineInterp - , pureBlockInterp ) where @@ -18,19 +16,20 @@ 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 :: BlockCommand - -> Maybe Page - -> Storage - -> SystemConfig - -> IO BlockElement + , bciInterpret :: InterpreterContext -> BlockCommand -> IO BlockElement + } + + +data InterpreterContext + = InterpreterContext { + ctxPage :: Maybe Page + , ctxTree :: WikiPage + , ctxStorage :: Storage + , ctxSysConf :: SystemConfig } @@ -42,17 +41,3 @@ commandName (BlockCommandInterpreter name _) = name commandType :: Interpreter -> CommandType commandType (InlineCommandInterpreter _ _) = InlineCommandType commandType (BlockCommandInterpreter _ _) = BlockCommandType - - -pureInlineInterp :: String - -> (InlineCommand -> Maybe Page -> InlineElement) - -> Interpreter -pureInlineInterp name f - = InlineCommandInterpreter name $ \ cmd page _ _ -> return $ f cmd page - - -pureBlockInterp :: String - -> (BlockCommand -> Maybe Page -> BlockElement) - -> Interpreter -pureBlockInterp name f - = BlockCommandInterpreter name $ \ cmd page _ _ -> return $ f cmd page