diff options
| author | John MacFarlane <[email protected]> | 2021-03-11 15:49:27 -0800 |
|---|---|---|
| committer | John MacFarlane <[email protected]> | 2021-03-13 15:05:37 -0800 |
| commit | 8be95ad8e5150d5cab66c4abdf59baaf4670c6c8 (patch) | |
| tree | 9655036efbaabda6a2a7802dc971c7fba5a987ca /src/Text/Pandoc/Lua | |
| parent | 35b66a76718205c303f416bf0afc01c098e8a171 (diff) | |
Use custom Prelude based on relude.relude
The Prelude now longer exports partial functions, so
a large number of uses of these functions in the
code base have been rewritten.
A .ghci file has been added; this is necessary for
ghci to work properly with the custom Prelude.
Currently there are lots of compiler warnings.
We should either fix these or go to using a custom
Prelude that changes less than relude.
Diffstat (limited to 'src/Text/Pandoc/Lua')
| -rw-r--r-- | src/Text/Pandoc/Lua/Filter.hs | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/Lua/Marshaling/AST.hs | 13 | ||||
| -rw-r--r-- | src/Text/Pandoc/Lua/Marshaling/CommonState.hs | 5 | ||||
| -rw-r--r-- | src/Text/Pandoc/Lua/Marshaling/List.hs | 2 | ||||
| -rw-r--r-- | src/Text/Pandoc/Lua/Marshaling/ReaderOptions.hs | 3 | ||||
| -rw-r--r-- | src/Text/Pandoc/Lua/Module/Pandoc.hs | 3 |
6 files changed, 16 insertions, 12 deletions
diff --git a/src/Text/Pandoc/Lua/Filter.hs b/src/Text/Pandoc/Lua/Filter.hs index bffe01a34..07e13ab0c 100644 --- a/src/Text/Pandoc/Lua/Filter.hs +++ b/src/Text/Pandoc/Lua/Filter.hs @@ -204,7 +204,7 @@ walkMeta lf (Pandoc m bs) = do walkPandoc :: LuaFilter -> Pandoc -> Lua Pandoc walkPandoc (LuaFilter fnMap) = - case foldl mplus Nothing (map (`Map.lookup` fnMap) pandocFilterNames) of + case foldl' mplus Nothing (map (`Map.lookup` fnMap) pandocFilterNames) of Just fn -> \x -> runFilterFunction fn x *> singleElement x Nothing -> return diff --git a/src/Text/Pandoc/Lua/Marshaling/AST.hs b/src/Text/Pandoc/Lua/Marshaling/AST.hs index 8e12d232c..b9550ba75 100644 --- a/src/Text/Pandoc/Lua/Marshaling/AST.hs +++ b/src/Text/Pandoc/Lua/Marshaling/AST.hs @@ -1,6 +1,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TypeApplications #-} {- | Module : Text.Pandoc.Lua.Marshaling.AST Copyright : © 2012-2021 John MacFarlane @@ -78,12 +79,12 @@ instance Peekable Citation where <*> LuaUtil.rawField idx "hash" instance Pushable Alignment where - push = Lua.push . show + push = Lua.push . show @String instance Peekable Alignment where peek = Lua.peekRead instance Pushable CitationMode where - push = Lua.push . show + push = Lua.push . show @String instance Peekable CitationMode where peek = Lua.peekRead @@ -93,22 +94,22 @@ instance Peekable Format where peek idx = Format <$!> Lua.peek idx instance Pushable ListNumberDelim where - push = Lua.push . show + push = Lua.push . show @String instance Peekable ListNumberDelim where peek = Lua.peekRead instance Pushable ListNumberStyle where - push = Lua.push . show + push = Lua.push . show @String instance Peekable ListNumberStyle where peek = Lua.peekRead instance Pushable MathType where - push = Lua.push . show + push = Lua.push . show @String instance Peekable MathType where peek = Lua.peekRead instance Pushable QuoteType where - push = Lua.push . show + push = Lua.push . show @String instance Peekable QuoteType where peek = Lua.peekRead diff --git a/src/Text/Pandoc/Lua/Marshaling/CommonState.hs b/src/Text/Pandoc/Lua/Marshaling/CommonState.hs index 147197c5d..7701ac35b 100644 --- a/src/Text/Pandoc/Lua/Marshaling/CommonState.hs +++ b/src/Text/Pandoc/Lua/Marshaling/CommonState.hs @@ -1,6 +1,7 @@ {-# OPTIONS_GHC -fno-warn-orphans #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TypeApplications #-} {- | Module : Text.Pandoc.Lua.Marshaling.CommonState Copyright : © 2012-2021 John MacFarlane @@ -66,7 +67,7 @@ pairsCommonState st = do (key, pushValue):_ -> 2 <$ (Lua.push key *> pushValue st) Lua.TypeString -> do key <- Lua.peek idx - case tail $ dropWhile ((/= key) . fst) commonStateFields of + case drop 1 $ dropWhile ((/= key) . fst) commonStateFields of [] -> 2 <$ (Lua.pushnil *> Lua.pushnil) (nextKey, pushValue):_ -> 2 <$ (Lua.push nextKey *> pushValue st) _ -> 2 <$ (Lua.pushnil *> Lua.pushnil) @@ -81,7 +82,7 @@ commonStateFields = , ("source_url", Lua.push . Lua.Optional . stSourceURL) , ("user_data_dir", Lua.push . Lua.Optional . stUserDataDir) , ("trace", Lua.push . stTrace) - , ("verbosity", Lua.push . show . stVerbosity) + , ("verbosity", Lua.push . show @String . stVerbosity) ] -- | Name used by Lua for the @CommonState@ type. diff --git a/src/Text/Pandoc/Lua/Marshaling/List.hs b/src/Text/Pandoc/Lua/Marshaling/List.hs index 0446302a1..fcc43b0ca 100644 --- a/src/Text/Pandoc/Lua/Marshaling/List.hs +++ b/src/Text/Pandoc/Lua/Marshaling/List.hs @@ -20,8 +20,8 @@ import Data.Data (Data) import Foreign.Lua (Peekable, Pushable) import Text.Pandoc.Walk (Walkable (..)) import Text.Pandoc.Lua.Util (defineHowTo, pushViaConstructor) - import qualified Foreign.Lua as Lua +import Prelude hiding (fromList) -- | List wrapper which is marshalled as @pandoc.List@. newtype List a = List { fromList :: [a] } diff --git a/src/Text/Pandoc/Lua/Marshaling/ReaderOptions.hs b/src/Text/Pandoc/Lua/Marshaling/ReaderOptions.hs index dd7bf2e61..01af3660b 100644 --- a/src/Text/Pandoc/Lua/Marshaling/ReaderOptions.hs +++ b/src/Text/Pandoc/Lua/Marshaling/ReaderOptions.hs @@ -1,4 +1,5 @@ {-# LANGUAGE LambdaCase #-} +{-# LANGUAGE TypeApplications #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} {-# OPTIONS_GHC -fno-warn-orphans #-} @@ -31,7 +32,7 @@ import qualified Text.Pandoc.Lua.Util as LuaUtil -- Reader Options -- instance Pushable Extensions where - push exts = Lua.push (show exts) + push exts = Lua.push (show @String exts) instance Pushable TrackChanges where push = Lua.push . showConstr . toConstr diff --git a/src/Text/Pandoc/Lua/Module/Pandoc.hs b/src/Text/Pandoc/Lua/Module/Pandoc.hs index 8d30f9a0c..c06b556ce 100644 --- a/src/Text/Pandoc/Lua/Module/Pandoc.hs +++ b/src/Text/Pandoc/Lua/Module/Pandoc.hs @@ -1,5 +1,6 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE TypeApplications #-} {- | Module : Text.Pandoc.Lua.Module.Pandoc Copyright : Copyright © 2017-2021 Albert Krewinkel @@ -77,7 +78,7 @@ read content formatSpecOrNil = liftPandocLua $ do "Unknown reader: " <> f Left (PandocUnsupportedExtensionError e f) -> Lua.raiseError $ "Extension " <> e <> " not supported for " <> f - Left e -> Lua.raiseError $ show e + Left e -> Lua.raiseError $ show @String e -- | Pipes input through a command. pipe :: String -- ^ path to executable |
