/pony-maybe

Utilities for working with optional values in Pony :horse: :no_entry_sign:

Primary LanguagePony

pony-maybe

Utilities for handling optional data in Pony.

Status

CircleCI

Installation

  • Install corral
  • corral add github.com/mfelsche/pony-maybe.git --version master
  • corral fetch to fetch your dependencies
  • use "maybe" to include this package
  • corral run -- ponyc to compile your application

Usage

use "maybe"

class WithOptionalStuff
  let _stuff: Maybe[String] = None

  fun update_stuff(new_stuff: String): Maybe[String] =>
    _stuff = new_stuff

  fun size(): USize =>
    Opt.get[USize](
      Opt.map[String, USize](_stuff, {(s) => s.size() }),
      0
    )