plum

#treesitter#compiler#wasm

git clone https://git.pyrossh.dev/plum

A statically typed, imperative programming language inspired by rust, python


plum-std/Bool.plum
module std
import std/Result
import std/Str

enum Bool =
  | True
  | False

  fun parse(v: Str) -> Result[Bool, Str] =
    if v == "true"
      Ok(True)
    else if v == "false"
      Ok(False)
    else
      Err("could not parse bool from '{v}'")

  fun and(self, o: Bool) -> Bool =
    match self, o
      True, True => True
      True, False => False
      False, True => False
      False, False => False

  fun or(self, o: Bool) -> Bool =
    match self, o
      True, True => True
      True, False => True
      False, True => True
      False, False => False

  fun toStr(self) -> Str =
    match self
      True => "True"
      False => "False"