Skip to content

Commit

Permalink
argument at method
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Oct 23, 2024
1 parent 4fb9e1f commit 6b9b52f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Typst/Methods.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Control.Monad (MonadPlus (mplus), foldM, void)
import Control.Monad.Reader (MonadReader (ask), MonadTrans (lift))
import qualified Data.Array as Array
import qualified Data.Foldable as F
import Data.List (intersperse, sort, sortOn)
import Data.List (intersperse, sort, sortOn, (!?))
import qualified Data.Map as M
import qualified Data.Map.Ordered as OM
import Data.Maybe (fromMaybe, listToMaybe)
Expand Down Expand Up @@ -659,6 +659,12 @@ getMethod updateVal val fld = do
VArguments args ->
case fld of
"pos" -> pure $ makeFunction $ pure $ VArray $ V.fromList (positional args)
"at" ->
pure $ makeFunction $ do
(n :: Int) <- nthArg 1
case positional args !? n of
Nothing -> pure VNone
Just x -> pure x
"named" -> pure $ makeFunction $ pure $ VDict $ named args
_ -> noMethod "Arguments" fld
VDateTime mbdate mbtime -> do
Expand Down

0 comments on commit 6b9b52f

Please sign in to comment.