Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-environment

Environment files for Pudu: load .env variables safely with layered files, discovery, expansion, typed reads, and secrets kept out of every message

0.1.0Apache-2.01

InstallClose

Values.pudu

Pudu19 lines839 B

GitHub ↗
1/** @Domain.Values.Module — text to numbers and truth values */2module PuduLangEnvironment.Domain.Values34import Std.Decimal as Decimal5import Std.Text as Text6import PuduLangEnvironment.Constants.Names as Names78/// The whole number the text spells, with an optional sign, ignoring surrounding space.9export fn toInt(text: Str) -> Option[Int] { Text.wholeOf(text) }1011/// The floating-point number the text spells, ignoring surrounding space.12export fn toFloat(text: Str) -> Option[Float64] { text.trim().toFloat() }1314/// The exact decimal number the text spells, ignoring surrounding space.15export fn toDecimal(text: Str) -> Option[Decimal] { Decimal.parse(text.trim()) }1617/// `true` or `false` in any letter case, ignoring surrounding space.18export fn toBool(text: Str) -> Option[Bool] { Names.TRUTH_WORDS.get(text.trim().toLower()) }19