{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections #-}
module Text.Pandoc.Lua.Marshal.ListAttributes
( typeListAttributes
, peekListAttributes
, pushListAttributes
, mkListAttributes
, peekListNumberDelim
, pushListNumberDelim
, peekListNumberStyle
, pushListNumberStyle
) where
import Control.Applicative (optional)
import Data.Maybe (fromMaybe)
import HsLua
import Text.Pandoc.Definition
( ListAttributes, ListNumberStyle (..), ListNumberDelim (..))
typeListAttributes :: LuaError e => DocumentedType e ListAttributes
typeListAttributes :: forall e. LuaError e => DocumentedType e ListAttributes
typeListAttributes = forall e a.
LuaError e =>
Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) a]
-> DocumentedType e a
deftype Name
"ListAttributes"
[ forall e.
Operation
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
operation Operation
Eq forall a b. (a -> b) -> a -> b
$ forall a e. a -> HsFnPrecursor e a
lambda
### liftPure2 (\a b -> fromMaybe False ((==) <$> a <*> b))
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter (forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall e. LuaError e => Peeker e ListAttributes
peekListAttributes) Text
"a" Text
"ListAttributes" Text
""
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter (forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall e. LuaError e => Peeker e ListAttributes
peekListAttributes) Text
"b" Text
"ListAttributes" Text
""
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult forall e. Pusher e Bool
pushBool Text
"boolean" Text
"whether the two are equal"
]
[ forall e b a fn.
LuaError e =>
Name
-> Text
-> (Pusher e b, a -> b)
-> (Peeker e b, a -> b -> a)
-> Member e fn a
property Name
"start" Text
"number of the first list item"
(forall a e. (Integral a, Show a) => a -> LuaE e ()
pushIntegral, \(Int
start,ListNumberStyle
_,ListNumberDelim
_) -> Int
start)
(forall a e. (Integral a, Read a) => Peeker e a
peekIntegral, \(Int
_,ListNumberStyle
style,ListNumberDelim
delim) -> (,ListNumberStyle
style,ListNumberDelim
delim))
, forall e b a fn.
LuaError e =>
Name
-> Text
-> (Pusher e b, a -> b)
-> (Peeker e b, a -> b -> a)
-> Member e fn a
property Name
"style" Text
"style used for list numbering"
(forall e. Pusher e ListNumberStyle
pushListNumberStyle, \(Int
_,ListNumberStyle
style,ListNumberDelim
_) -> ListNumberStyle
style)
(forall e. Peeker e ListNumberStyle
peekListNumberStyle, \(Int
start,ListNumberStyle
_,ListNumberDelim
delim) -> (Int
start,,ListNumberDelim
delim))
, forall e b a fn.
LuaError e =>
Name
-> Text
-> (Pusher e b, a -> b)
-> (Peeker e b, a -> b -> a)
-> Member e fn a
property Name
"delimiter" Text
"delimiter of list numbers"
(forall e. Pusher e ListNumberDelim
pushListNumberDelim, \(Int
_,ListNumberStyle
_,ListNumberDelim
delim) -> ListNumberDelim
delim)
(forall e. Peeker e ListNumberDelim
peekListNumberDelim, \(Int
start,ListNumberStyle
style,ListNumberDelim
_) -> (Int
start,ListNumberStyle
style,))
, forall e a.
DocumentedFunction e -> Member e (DocumentedFunction e) a
method forall a b. (a -> b) -> a -> b
$ forall a e. Name -> a -> HsFnPrecursor e a
defun Name
"clone"
### return
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> forall e a itemtype.
LuaError e =>
DocumentedTypeWithList e a itemtype
-> Text -> Text -> Parameter e a
udparam forall e. LuaError e => DocumentedType e ListAttributes
typeListAttributes Text
"a" Text
""
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult (forall e fn a itemtype.
LuaError e =>
UDTypeWithList e fn a itemtype -> a -> LuaE e ()
pushUD forall e. LuaError e => DocumentedType e ListAttributes
typeListAttributes) Text
"ListAttributes"
Text
"cloned ListAttributes value"
]
pushListAttributes :: LuaError e => Pusher e ListAttributes
pushListAttributes :: forall e. LuaError e => Pusher e ListAttributes
pushListAttributes = forall e fn a itemtype.
LuaError e =>
UDTypeWithList e fn a itemtype -> a -> LuaE e ()
pushUD forall e. LuaError e => DocumentedType e ListAttributes
typeListAttributes
peekListAttributes :: LuaError e => Peeker e ListAttributes
peekListAttributes :: forall e. LuaError e => Peeker e ListAttributes
peekListAttributes = forall e a. Name -> Peek e a -> Peek e a
retrieving Name
"ListAttributes" forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall e a. LuaError e => [Peeker e a] -> Peeker e a
choice
[ forall e fn a itemtype.
LuaError e =>
UDTypeWithList e fn a itemtype -> Peeker e a
peekUD forall e. LuaError e => DocumentedType e ListAttributes
typeListAttributes
, forall e a b c.
LuaError e =>
Peeker e a -> Peeker e b -> Peeker e c -> Peeker e (a, b, c)
peekTriple forall a e. (Integral a, Read a) => Peeker e a
peekIntegral forall a e. Read a => Peeker e a
peekRead forall a e. Read a => Peeker e a
peekRead
]
mkListAttributes :: LuaError e => DocumentedFunction e
mkListAttributes :: forall e. LuaError e => DocumentedFunction e
mkListAttributes = forall a e. Name -> a -> HsFnPrecursor e a
defun Name
"ListAttributes"
### liftPure3 (\mstart mstyle mdelim ->
( fromMaybe 1 mstart
, fromMaybe DefaultStyle mstyle
, fromMaybe DefaultDelim mdelim
))
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> forall e a. Parameter e a -> Parameter e (Maybe a)
opt (forall a e. (Read a, Integral a) => Text -> Text -> Parameter e a
integralParam Text
"start" Text
"number of first item")
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> forall e a. Parameter e a -> Parameter e (Maybe a)
opt (forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter forall a e. Read a => Peeker e a
peekRead Text
"string" Text
"style" Text
"list numbering style")
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> forall e a. Parameter e a -> Parameter e (Maybe a)
opt (forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter forall a e. Read a => Peeker e a
peekRead Text
"string" Text
"delimiter" Text
"list number delimiter")
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> forall e a itemtype.
LuaError e =>
DocumentedTypeWithList e a itemtype -> Text -> FunctionResults e a
udresult forall e. LuaError e => DocumentedType e ListAttributes
typeListAttributes Text
"new ListAttributes"
#? "Creates a new ListAttributes object."
pushListNumberDelim :: Pusher e ListNumberDelim
pushListNumberDelim :: forall e. Pusher e ListNumberDelim
pushListNumberDelim = forall e. String -> LuaE e ()
pushString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show
{-# INLINE pushListNumberDelim #-}
peekListNumberDelim :: Peeker e ListNumberDelim
peekListNumberDelim :: forall e. Peeker e ListNumberDelim
peekListNumberDelim = forall a e. Read a => Peeker e a
peekRead
{-# INLINE peekListNumberDelim #-}
pushListNumberStyle :: Pusher e ListNumberStyle
pushListNumberStyle :: forall e. Pusher e ListNumberStyle
pushListNumberStyle = forall e. String -> LuaE e ()
pushString forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. Show a => a -> String
show
{-# INLINE pushListNumberStyle #-}
peekListNumberStyle :: Peeker e ListNumberStyle
peekListNumberStyle :: forall e. Peeker e ListNumberStyle
peekListNumberStyle = forall a e. Read a => Peeker e a
peekRead
{-# INLINE peekListNumberStyle #-}