git.iko.soy/typeable/pandoc
on master help sign in
Add type annotations to assist ghci.
8ed7497John MacFarlane
src/Text/Pandoc/Lua/Marshaling/ReaderOptions.hs+3−1
@@ -1,6 +1,7 @@
1{-# LANGUAGE NoImplicitPrelude #-}
1{-# LANGUAGE NoImplicitPrelude #-}
2{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE FlexibleInstances #-}
3{-# LANGUAGE ScopedTypeVariables #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4+{-# LANGUAGE OverloadedStrings #-}
4{-# LANGUAGE LambdaCase #-}
5{-# LANGUAGE LambdaCase #-}
5{-# OPTIONS_GHC -fno-warn-orphans #-}
6{-# OPTIONS_GHC -fno-warn-orphans #-}
6{- |
7{- |
@@ -67,7 +68,8 @@ instance Pushable ReaderOptions where
67 indexReaderOptions _tbl (AnyValue key) = do
68 indexReaderOptions _tbl (AnyValue key) = do
68 Lua.ltype key >>= \case
69 Lua.ltype key >>= \case
69 Lua.TypeString -> Lua.peek key >>= \case
70 Lua.TypeString -> Lua.peek key >>= \case
71+ ("defaultImageExtension" :: Text.Text)
70− "defaultImageExtension" -> Lua.push defaultImageExtension
72+ -> Lua.push defaultImageExtension
71 "indentedCodeClasses" -> Lua.push indentedCodeClasses
73 "indentedCodeClasses" -> Lua.push indentedCodeClasses
72 "stripComments" -> Lua.push stripComments
74 "stripComments" -> Lua.push stripComments
73 "tabStop" -> Lua.push tabStop
75 "tabStop" -> Lua.push tabStop
src/Text/Pandoc/Lua/Marshaling/Version.hs+3−1
@@ -1,6 +1,7 @@
1{-# OPTIONS_GHC -fno-warn-orphans #-}
1{-# OPTIONS_GHC -fno-warn-orphans #-}
2{-# LANGUAGE LambdaCase #-}
2{-# LANGUAGE LambdaCase #-}
3{-# LANGUAGE NoImplicitPrelude #-}
3{-# LANGUAGE NoImplicitPrelude #-}
4+{-# LANGUAGE OverloadedStrings #-}
4{- |
5{- |
5 Module : Text.Pandoc.Lua.Marshaling.Version
6 Module : Text.Pandoc.Lua.Marshaling.Version
6 Copyright : © 2019 Albert Krewinkel
7 Copyright : © 2019 Albert Krewinkel
@@ -19,6 +20,7 @@ module Text.Pandoc.Lua.Marshaling.Version
19 where
20 where
20
21
21import Prelude
22import Prelude
23+import Data.Text (Text)
22import Data.Maybe (fromMaybe)
24import Data.Maybe (fromMaybe)
23import Data.Version (Version (..), makeVersion, parseVersion, showVersion)
25import Data.Version (Version (..), makeVersion, parseVersion, showVersion)
24import Foreign.Lua (Lua, Optional (..), NumResults,
26import Foreign.Lua (Lua, Optional (..), NumResults,
@@ -103,7 +105,7 @@ __index v (AnyValue k) = do
103 Lua.push (Lua.Optional versionPart)
105 Lua.push (Lua.Optional versionPart)
104 return 1
106 return 1
105 Lua.TypeString -> do
107 Lua.TypeString -> do
106− str <- Lua.peek k
108+ (str :: Text) <- Lua.peek k
107 if str == "must_be_at_least"
109 if str == "must_be_at_least"
108 then 1 <$ Lua.pushHaskellFunction must_be_at_least
110 then 1 <$ Lua.pushHaskellFunction must_be_at_least
109 else 1 <$ Lua.pushnil
111 else 1 <$ Lua.pushnil
src/Text/Pandoc/Lua/Module/MediaBag.hs+4−3
@@ -1,4 +1,5 @@
1{-# LANGUAGE NoImplicitPrelude #-}
1{-# LANGUAGE NoImplicitPrelude #-}
2+{-# LANGUAGE OverloadedStrings #-}
2{- |
3{- |
3 Module : Text.Pandoc.Lua.Module.MediaBag
4 Module : Text.Pandoc.Lua.Module.MediaBag
4 Copyright : Copyright © 2017-2019 Albert Krewinkel
5 Copyright : Copyright © 2017-2019 Albert Krewinkel
@@ -108,9 +109,9 @@ mediaDirectoryFn = do
108 addEntry :: Lua.Integer -> (FilePath, MimeType, Int) -> Lua ()
109 addEntry :: Lua.Integer -> (FilePath, MimeType, Int) -> Lua ()
109 addEntry idx (fp, mimeType, contentLength) = do
110 addEntry idx (fp, mimeType, contentLength) = do
110 Lua.newtable
111 Lua.newtable
111− Lua.push "path" *> Lua.push fp *> Lua.rawset (-3)
112+ Lua.push ("path" :: T.Text) *> Lua.push fp *> Lua.rawset (-3)
112− Lua.push "type" *> Lua.push mimeType *> Lua.rawset (-3)
113+ Lua.push ("type" :: T.Text) *> Lua.push mimeType *> Lua.rawset (-3)
113− Lua.push "length" *> Lua.push contentLength *> Lua.rawset (-3)
114+ Lua.push ("length" :: T.Text) *> Lua.push contentLength *> Lua.rawset (-3)
114 Lua.rawseti (-2) idx
115 Lua.rawseti (-2) idx
115
116
116fetch :: T.Text
117fetch :: T.Text
src/Text/Pandoc/Lua/Util.hs+3−2
@@ -1,6 +1,7 @@
1{-# LANGUAGE FlexibleInstances #-}
1{-# LANGUAGE FlexibleInstances #-}
2{-# LANGUAGE LambdaCase #-}
2{-# LANGUAGE LambdaCase #-}
3{-# LANGUAGE NoImplicitPrelude #-}
3{-# LANGUAGE NoImplicitPrelude #-}
4+{-# LANGUAGE OverloadedStrings #-}
4{- |
5{- |
5 Module : Text.Pandoc.Lua.Util
6 Module : Text.Pandoc.Lua.Util
6 Copyright : © 2012–2019 John MacFarlane,
7 Copyright : © 2012–2019 John MacFarlane,
@@ -31,9 +32,9 @@ import Control.Monad (unless, when)
31import Foreign.Lua ( Lua, NumArgs, NumResults, Peekable, Pushable, StackIndex
32import Foreign.Lua ( Lua, NumArgs, NumResults, Peekable, Pushable, StackIndex
32 , Status, ToHaskellFunction )
33 , Status, ToHaskellFunction )
33import Text.Pandoc.Class (readDataFile, runIOorExplode, setUserDataDir)
34import Text.Pandoc.Class (readDataFile, runIOorExplode, setUserDataDir)
34−
35import qualified Foreign.Lua as Lua
35import qualified Foreign.Lua as Lua
36import qualified Text.Pandoc.UTF8 as UTF8
36import qualified Text.Pandoc.UTF8 as UTF8
37+import Data.Text (Text)
37
38
38-- | Get value behind key from table at given index.
39-- | Get value behind key from table at given index.
39rawField :: Peekable a => StackIndex -> String -> Lua a
40rawField :: Peekable a => StackIndex -> String -> Lua a
@@ -104,7 +105,7 @@ getTag :: StackIndex -> Lua String
104getTag idx = do
105getTag idx = do
105 -- push metatable or just the table
106 -- push metatable or just the table
106 Lua.getmetatable idx >>= \hasMT -> unless hasMT (Lua.pushvalue idx)
107 Lua.getmetatable idx >>= \hasMT -> unless hasMT (Lua.pushvalue idx)
107− Lua.push "tag"
108+ Lua.push ("tag" :: Text)
108 Lua.rawget (Lua.nthFromTop 2)
109 Lua.rawget (Lua.nthFromTop 2)
109 Lua.tostring Lua.stackTop <* Lua.pop 2 >>= \case
110 Lua.tostring Lua.stackTop <* Lua.pop 2 >>= \case
110 Nothing -> Lua.throwException "untagged value"
111 Nothing -> Lua.throwException "untagged value"