diff options
author | Albert Krewinkel <albert@zeitkraut.de> | 2017-08-13 17:48:43 +0200 |
---|---|---|
committer | Albert Krewinkel <albert@zeitkraut.de> | 2017-08-13 17:48:43 +0200 |
commit | 3d87e2080a27618e70edd1ff2d4160ff959732a6 (patch) | |
tree | 6e5e9132e005e76588c0aa83acfeab24511ba2d5 /src/Text/Pandoc/Lua/PandocModule.hs | |
parent | 6e6cee454eab678b8ad3b15edcee6e07945157ba (diff) | |
download | pandoc-3d87e2080a27618e70edd1ff2d4160ff959732a6.tar.gz |
Delete Text.Pandoc.Lua.SharedInstances
Stack instances for common data types are now provides by hslua. The
instance for Either was useful only for a very specific case; the
function that was using the `ToLuaStack Either` instance was rewritten
to work without it.
Closes: #3805
Diffstat (limited to 'src/Text/Pandoc/Lua/PandocModule.hs')
-rw-r--r-- | src/Text/Pandoc/Lua/PandocModule.hs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/Text/Pandoc/Lua/PandocModule.hs b/src/Text/Pandoc/Lua/PandocModule.hs index c8eaf3da0..afb9aeca6 100644 --- a/src/Text/Pandoc/Lua/PandocModule.hs +++ b/src/Text/Pandoc/Lua/PandocModule.hs @@ -31,10 +31,9 @@ import Control.Monad (unless) import Data.ByteString.Char8 (unpack) import Data.Default (Default (..)) import Data.Text (pack) -import Foreign.Lua (Lua, Status (OK), liftIO, push, pushHaskellFunction) -import Foreign.Lua.Api (call, loadstring, rawset) -import Text.Pandoc.Class -import Text.Pandoc.Definition (Pandoc) +import Foreign.Lua (Lua, Status (OK), NumResults, call, loadstring, liftIO, + push, pushHaskellFunction, rawset) +import Text.Pandoc.Class (readDataFile, runIO, runIOorExplode, setUserDataDir) import Text.Pandoc.Options (ReaderOptions(readerExtensions)) import Text.Pandoc.Lua.StackInstances () import Text.Pandoc.Readers (Reader (..), getReader) @@ -54,16 +53,17 @@ pandocModuleScript :: Maybe FilePath -> IO String pandocModuleScript datadir = unpack <$> runIOorExplode (setUserDataDir datadir >> readDataFile "pandoc.lua") -readDoc :: String -> String -> Lua (Either String Pandoc) -readDoc formatSpec content = liftIO $ do +readDoc :: String -> String -> Lua NumResults +readDoc formatSpec content = do case getReader formatSpec of - Left s -> return $ Left s + Left s -> push s -- Unknown reader Right (reader, es) -> case reader of TextReader r -> do - res <- runIO $ r def{ readerExtensions = es } (pack content) + res <- liftIO $ runIO $ r def{ readerExtensions = es } (pack content) case res of - Left s -> return . Left $ show s - Right pd -> return $ Right pd - _ -> return $ Left "Only string formats are supported at the moment." + Left s -> push $ show s -- error while reading + Right pd -> push pd -- success, push Pandoc + _ -> push "Only string formats are supported at the moment." + return 1 |