GraphQ...peCheck(3pm)

πŸ“¦
version 0.54 Β· 2 versions
  • 0.54 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.53 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ GraphQL::MaybeTypeCheck ✨

okay bestie, so this is a page from the User Contributed Perl Documentation (section 3pm of the manual, if you're keeping track) and it's genuinely one of the cutest little runtime helpers out there. let's get into it 🫢


πŸ’– NAME πŸ’–

GraphQL::MaybeTypeCheck β€” conditional type-checking at runtime

like… it type-checks. but only maybe. it's giving low-commitment queen. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

use GraphQL::MaybeTypeCheck;

method foo(
  $arg1 Str,
  $arg2 Int
) :ReturnType(Map[Str, Int]) {
  # ...
}

see how the types are just… there? Str, Int, Map[Str, Int]?? iconic. no cap. ✨


🌸 DESCRIPTION 🌸

so here's the tea β˜• β€” this module optionally enables type-checking in the caller, and the checking itself is implemented by Function::Parameters and Return::Type. whether it actually does anything depends entirely on whether Devel::StrictMode is activated. it's basically a vibe check for your type checks. πŸ’€


πŸ”₯ Devel::StrictMode ON πŸ”₯

when Devel::StrictMode is active, this module will import Function::Parameters into the caller with its default configuration. as of writing, that includes checking both argument count and type. so yeah, it's locked in fr fr πŸ‘‘

and when you're in strict mode, it also requires Return::Type, which registers the ReturnType attribute. that's the little :ReturnType(...) glow-up you saw in the synopsis. πŸ’–


🌈 Devel::StrictMode OFF 🌈

when strict mode is inactive, this module still imports Function::Parameters into the caller β€” it's not ghosting you β€” BUT it sets fun and method to lax mode and disables argument type checking. chill vibes only. πŸ¦‹

it also installs a no-op ReturnType attribute, so your existing syntax doesn't break. the drip stays, the enforcement dips. 😌✨

ngl bestie, the whole point is: same code, same syntax, and strict mode just decides whether the types actually mean something. no rewriting required. periodt. πŸ’…

πŸ’œ sign-off πŸ’œ

this lil page was rendered by perl v5.34.0 and dated 2022-03-27, and honestly it ate. go forth and type-check conditionally, my main character πŸ§šβ€β™€οΈβ­πŸ’–

πŸ“¦ where this page comes from