{-# LANGUAGE OverloadedStrings #-}
module Text.Pandoc.Lua.Marshal.TableHead
( peekTableHead
, pushTableHead
, typeTableHead
, mkTableHead
) where
import Control.Applicative (optional)
import Data.Maybe (fromMaybe)
import HsLua
import Text.Pandoc.Lua.Marshal.Attr (peekAttr, pushAttr)
import Text.Pandoc.Lua.Marshal.List (pushPandocList)
import Text.Pandoc.Lua.Marshal.Row (peekRowFuzzy, pushRow)
import Text.Pandoc.Definition
pushTableHead :: LuaError e => TableHead -> LuaE e ()
pushTableHead :: TableHead -> LuaE e ()
pushTableHead = UDTypeWithList e (DocumentedFunction e) TableHead Void
-> TableHead -> LuaE e ()
forall e fn a itemtype.
LuaError e =>
UDTypeWithList e fn a itemtype -> a -> LuaE e ()
pushUD UDTypeWithList e (DocumentedFunction e) TableHead Void
forall e. LuaError e => DocumentedType e TableHead
typeTableHead
peekTableHead :: LuaError e => Peeker e TableHead
peekTableHead :: Peeker e TableHead
peekTableHead = UDTypeWithList e (DocumentedFunction e) TableHead Void
-> Peeker e TableHead
forall e fn a itemtype.
LuaError e =>
UDTypeWithList e fn a itemtype -> Peeker e a
peekUD UDTypeWithList e (DocumentedFunction e) TableHead Void
forall e. LuaError e => DocumentedType e TableHead
typeTableHead
typeTableHead :: LuaError e => DocumentedType e TableHead
typeTableHead :: DocumentedType e TableHead
typeTableHead = Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) TableHead]
-> DocumentedType e TableHead
forall e a.
LuaError e =>
Name
-> [(Operation, DocumentedFunction e)]
-> [Member e (DocumentedFunction e) a]
-> DocumentedType e a
deftype "pandoc TableHead"
[ Operation
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
forall e.
Operation
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
operation Operation
Eq (DocumentedFunction e -> (Operation, DocumentedFunction e))
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
forall a b. (a -> b) -> a -> b
$ Name
-> (Maybe TableHead -> Maybe TableHead -> LuaE e Bool)
-> HsFnPrecursor
e (Maybe TableHead -> Maybe TableHead -> LuaE e Bool)
forall a e. Name -> a -> HsFnPrecursor e a
defun "__eq"
### liftPure2 (\a b -> fromMaybe False ((==) <$> a <*> b))
HsFnPrecursor e (Maybe TableHead -> Maybe TableHead -> LuaE e Bool)
-> Parameter e (Maybe TableHead)
-> HsFnPrecursor e (Maybe TableHead -> LuaE e Bool)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Peeker e (Maybe TableHead)
-> Text -> Text -> Text -> Parameter e (Maybe TableHead)
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter (Peek e TableHead -> Peek e (Maybe TableHead)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Peek e TableHead -> Peek e (Maybe TableHead))
-> (StackIndex -> Peek e TableHead) -> Peeker e (Maybe TableHead)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackIndex -> Peek e TableHead
forall e. LuaError e => Peeker e TableHead
peekTableHead) "TableHead" "self" ""
HsFnPrecursor e (Maybe TableHead -> LuaE e Bool)
-> Parameter e (Maybe TableHead) -> HsFnPrecursor e (LuaE e Bool)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Peeker e (Maybe TableHead)
-> Text -> Text -> Text -> Parameter e (Maybe TableHead)
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter (Peek e TableHead -> Peek e (Maybe TableHead)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (Peek e TableHead -> Peek e (Maybe TableHead))
-> (StackIndex -> Peek e TableHead) -> Peeker e (Maybe TableHead)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StackIndex -> Peek e TableHead
forall e. LuaError e => Peeker e TableHead
peekTableHead) "any" "object" ""
HsFnPrecursor e (LuaE e Bool)
-> FunctionResults e Bool -> DocumentedFunction e
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> Pusher e Bool -> Text -> Text -> FunctionResults e Bool
forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult Pusher e Bool
forall e. Pusher e Bool
pushBool "boolean" "true iff the two values are equal"
, Operation
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
forall e.
Operation
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
operation Operation
Tostring (DocumentedFunction e -> (Operation, DocumentedFunction e))
-> DocumentedFunction e -> (Operation, DocumentedFunction e)
forall a b. (a -> b) -> a -> b
$ (TableHead -> LuaE e String)
-> HsFnPrecursor e (TableHead -> LuaE e String)
forall a e. a -> HsFnPrecursor e a
lambda
### liftPure show
HsFnPrecursor e (TableHead -> LuaE e String)
-> Parameter e TableHead -> HsFnPrecursor e (LuaE e String)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> (StackIndex -> Peek e TableHead)
-> Text -> Text -> Text -> Parameter e TableHead
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter StackIndex -> Peek e TableHead
forall e. LuaError e => Peeker e TableHead
peekTableHead "TableHead" "self" ""
HsFnPrecursor e (LuaE e String)
-> FunctionResults e String -> DocumentedFunction e
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> Pusher e String -> Text -> Text -> FunctionResults e String
forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult Pusher e String
forall e. String -> LuaE e ()
pushString "string" "native Haskell representation"
]
[ Name
-> Text
-> (Pusher e Attr, TableHead -> Attr)
-> (Peeker e Attr, TableHead -> Attr -> TableHead)
-> Member e (DocumentedFunction e) TableHead
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 "attr" "table head attributes"
(Pusher e Attr
forall e. LuaError e => Pusher e Attr
pushAttr, \(TableHead attr :: Attr
attr _) -> Attr
attr)
(Peeker e Attr
forall e. LuaError e => Peeker e Attr
peekAttr, \(TableHead _ cells :: [Row]
cells) attr :: Attr
attr ->
Attr -> [Row] -> TableHead
TableHead Attr
attr [Row]
cells)
, Name
-> Text
-> (Pusher e [Row], TableHead -> [Row])
-> (Peeker e [Row], TableHead -> [Row] -> TableHead)
-> Member e (DocumentedFunction e) TableHead
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 "rows" "header rows"
(Pusher e Row -> Pusher e [Row]
forall e a. LuaError e => Pusher e a -> Pusher e [a]
pushPandocList Pusher e Row
forall e. LuaError e => Row -> LuaE e ()
pushRow, \(TableHead _ rows :: [Row]
rows) -> [Row]
rows)
(Peeker e Row -> Peeker e [Row]
forall a e. LuaError e => Peeker e a -> Peeker e [a]
peekList Peeker e Row
forall e. LuaError e => Peeker e Row
peekRowFuzzy, \(TableHead attr :: Attr
attr _) rows :: [Row]
rows ->
Attr -> [Row] -> TableHead
TableHead Attr
attr [Row]
rows)
, AliasIndex
-> Text
-> [AliasIndex]
-> Member e (DocumentedFunction e) TableHead
forall e fn a. AliasIndex -> Text -> [AliasIndex] -> Member e fn a
alias "identifier" "cell ID" ["attr", "identifier"]
, AliasIndex
-> Text
-> [AliasIndex]
-> Member e (DocumentedFunction e) TableHead
forall e fn a. AliasIndex -> Text -> [AliasIndex] -> Member e fn a
alias "classes" "cell classes" ["attr", "classes"]
, AliasIndex
-> Text
-> [AliasIndex]
-> Member e (DocumentedFunction e) TableHead
forall e fn a. AliasIndex -> Text -> [AliasIndex] -> Member e fn a
alias "attributes" "cell attributes" ["attr", "attributes"]
, DocumentedFunction e -> Member e (DocumentedFunction e) TableHead
forall e a.
DocumentedFunction e -> Member e (DocumentedFunction e) a
method (DocumentedFunction e -> Member e (DocumentedFunction e) TableHead)
-> DocumentedFunction e
-> Member e (DocumentedFunction e) TableHead
forall a b. (a -> b) -> a -> b
$ Name
-> (TableHead -> LuaE e TableHead)
-> HsFnPrecursor e (TableHead -> LuaE e TableHead)
forall a e. Name -> a -> HsFnPrecursor e a
defun "clone"
### return
HsFnPrecursor e (TableHead -> LuaE e TableHead)
-> Parameter e TableHead -> HsFnPrecursor e (LuaE e TableHead)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> (StackIndex -> Peek e TableHead)
-> Text -> Text -> Text -> Parameter e TableHead
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter StackIndex -> Peek e TableHead
forall e. LuaError e => Peeker e TableHead
peekTableHead "TableHead" "self" ""
HsFnPrecursor e (LuaE e TableHead)
-> FunctionResults e TableHead -> DocumentedFunction e
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> Pusher e TableHead -> Text -> Text -> FunctionResults e TableHead
forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult Pusher e TableHead
forall e. LuaError e => TableHead -> LuaE e ()
pushTableHead "TableHead" "cloned object"
]
mkTableHead :: LuaError e => DocumentedFunction e
mkTableHead :: DocumentedFunction e
mkTableHead = Name
-> (Maybe [Row] -> Maybe Attr -> LuaE e TableHead)
-> HsFnPrecursor e (Maybe [Row] -> Maybe Attr -> LuaE e TableHead)
forall a e. Name -> a -> HsFnPrecursor e a
defun "TableHead"
### liftPure2 (\mRows mAttr -> TableHead
(fromMaybe nullAttr mAttr)
(fromMaybe [] mRows))
HsFnPrecursor e (Maybe [Row] -> Maybe Attr -> LuaE e TableHead)
-> Parameter e (Maybe [Row])
-> HsFnPrecursor e (Maybe Attr -> LuaE e TableHead)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Parameter e [Row] -> Parameter e (Maybe [Row])
forall e a. Parameter e a -> Parameter e (Maybe a)
opt (Peeker e [Row] -> Text -> Text -> Text -> Parameter e [Row]
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter (Peeker e Row -> Peeker e [Row]
forall a e. LuaError e => Peeker e a -> Peeker e [a]
peekList Peeker e Row
forall e. LuaError e => Peeker e Row
peekRowFuzzy) "{Row,...}" "rows" "header rows")
HsFnPrecursor e (Maybe Attr -> LuaE e TableHead)
-> Parameter e (Maybe Attr) -> HsFnPrecursor e (LuaE e TableHead)
forall e a b.
HsFnPrecursor e (a -> b) -> Parameter e a -> HsFnPrecursor e b
<#> Parameter e Attr -> Parameter e (Maybe Attr)
forall e a. Parameter e a -> Parameter e (Maybe a)
opt (Peeker e Attr -> Text -> Text -> Text -> Parameter e Attr
forall e a. Peeker e a -> Text -> Text -> Text -> Parameter e a
parameter Peeker e Attr
forall e. LuaError e => Peeker e Attr
peekAttr "Attr" "attr" "table head attributes")
HsFnPrecursor e (LuaE e TableHead)
-> FunctionResults e TableHead -> DocumentedFunction e
forall e a.
HsFnPrecursor e (LuaE e a)
-> FunctionResults e a -> DocumentedFunction e
=#> Pusher e TableHead -> Text -> Text -> FunctionResults e TableHead
forall e a. Pusher e a -> Text -> Text -> FunctionResults e a
functionResult Pusher e TableHead
forall e. LuaError e => TableHead -> LuaE e ()
pushTableHead "TableHead" "new TableHead object"