{"id":16964989,"url":"https://github.com/propensive/vacuous","last_synced_at":"2025-04-11T23:04:42.114Z","repository":{"id":213310446,"uuid":"733553616","full_name":"propensive/vacuous","owner":"propensive","description":"A simple representation of optional values","archived":false,"fork":false,"pushed_at":"2025-01-25T18:29:46.000Z","size":1322,"stargazers_count":5,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-20T01:38:46.567Z","etag":null,"topics":["null-safety","optional-type","scala","union-types"],"latest_commit_sha":null,"homepage":"https://soundness.dev/vacuous/","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/propensive.png","metadata":{"files":{"readme":".github/readme.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-19T15:31:43.000Z","updated_at":"2025-01-25T18:29:50.000Z","dependencies_parsed_at":"2023-12-19T18:53:46.485Z","dependency_job_id":"4ec5fb67-c4c4-418c-a179-e9ee8e0b2da6","html_url":"https://github.com/propensive/vacuous","commit_stats":null,"previous_names":["propensive/vacuous"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fvacuous","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fvacuous/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fvacuous/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fvacuous/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/propensive","download_url":"https://codeload.github.com/propensive/vacuous/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239805884,"owners_count":19700202,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["null-safety","optional-type","scala","union-types"],"created_at":"2024-10-13T23:44:46.916Z","updated_at":"2025-02-20T08:31:38.527Z","avatar_url":"https://github.com/propensive.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"[\u003cimg alt=\"GitHub Workflow\" src=\"https://img.shields.io/github/actions/workflow/status/propensive/vacuous/main.yml?style=for-the-badge\" height=\"24\"\u003e](https://github.com/propensive/vacuous/actions)\n[\u003cimg src=\"https://img.shields.io/discord/633198088311537684?color=8899f7\u0026label=DISCORD\u0026style=for-the-badge\" height=\"24\"\u003e](https://discord.com/invite/MBUrkTgMnA)\n\u003cimg src=\"/doc/images/github.png\" valign=\"middle\"\u003e\n\n# Vacuous\n\n__A simple representation of optional values__\n\nScala's `Option` is the traditional way to represent values which may be either\n_present_ (in which case a value is specified) or _absent_. `Option` is a\nsimple ADT, but union types, along with some helper methods, can provide much\nbetter ergonomics in most circumstances. __Vacuous__ offers an `Optional` type\nwhich provides this functionality.\n\n## Features\n\n- Provides an implementation of optional values using union types\n- No need to wrap _present_ values in `Some`\n- Flattened representation, prohibiting ambiguous `Some(None)` representation\n- Lightweight `let`, `lay` and `or` methods cover `map`, `flatMap`, `fold`, `orElse` and `getOrElse`\n- Performant inlined implementations of all critical methods\n- Especially convenient use case for default parameters\n\n\n## Availability\n\nVacuous has not yet been published. The medium-term plan is to build it with\n[Fury](https://github.com/propensive/fury) and to publish it as a source build\non [Vent](https://github.com/propensive/vent). This will enable ordinary users\nto write and build software which depends on Vacuous.\n\nSubsequently, Vacuous will also be made available as a binary in the Maven\nCentral repository. This will enable users of other build tools to use it.\n\nFor the overeager, curious and impatient, see [building](#building).\n\n\n\n\n\n\n## Getting Started\n\n### The `Optional` type\n\nAn optional value, which might be an instance of `ValueType`, or may be\n_absent_, may be given the type `Optional[ValueType]`. If it is absent, then it\nhas the value, `Unset`, which is a singleton object. `Optional[ValueType]` is\nan alias for the union type, `ValueType | Unset.type`.\n\nNote that the declarations,\n```scala\nval value: Text = t\"Hello world\"\n```\nand,\n```scala\nval value: Optional[Text] = t\"Hello world\"\n```\ndiffer only in their types; the syntax of the expression is identical, and does\nnot need to be wrapped with another factory method, like `Some`.\n\nSince union types are unordered sets of types, nesting two `Optional`s, for\nexample in `Optional[Optional[Int]]` expands to\n`Int | Unset.type | Unset.type`, which is identical to `Int | Unset.type`. And\nthis is the same as `Optional[Int]`. While there is nothing to prevent nesting\none `Optional` within another `Optional`, it's impossible to distinguish\nbetween the types, and impossible for an `Unset` value to be considered\n_present_ rather than _absent_; it is the definition of absence.\n\n### `or`, `let` and `lay`\n\nAn `Optional[Text]` value may seem very similar to a `Text` value, but the\npossibility that it might be `Unset` makes it impossible to use any methods\ndefined on `Text` on an `Optional[Text]`, since those methods are not\napplicable to just one of the possible values of the type, `Unset`. So several\nconvenience methods are provided to make `Optional`s easy to work with.\n\nThe method `or` replaces the `Unset` value with another value, eliminating the\noptionality from the type. This is equivalent to _both_ `getOrElse` and\n`orElse` on `Option`. This equivalence comes from the lack of nesting of\n`Optional` values.\n\nSimilarly, `let` applies a lambda to the _present_ values, and leaves the\n_absent_ value unchanged. It is equivalent to both `map` and `flatMap` on\n`Option`s.\n\nFinally, `lay` combines `or` and `let` in a single, two-parameter method: the\nalternative value for `Unset` is specified first, followed by the lambda\nmapping the _present_ values. This is equivalent to `fold` on an `Option`.\n\nThese method names were deliberately chosen to be short, as they are intended\nto be used frequently and are rarely the most interesting part of an\nexpression.\n\n\n\n## Status\n\nVacuous is classified as __maturescent__. For reference, Soundness projects are\ncategorized into one of the following five stability levels:\n\n- _embryonic_: for experimental or demonstrative purposes only, without any guarantees of longevity\n- _fledgling_: of proven utility, seeking contributions, but liable to significant redesigns\n- _maturescent_: major design decisions broady settled, seeking probatory adoption and refinement\n- _dependable_: production-ready, subject to controlled ongoing maintenance and enhancement; tagged as version `1.0.0` or later\n- _adamantine_: proven, reliable and production-ready, with no further breaking changes ever anticipated\n\nProjects at any stability level, even _embryonic_ projects, can still be used,\nas long as caution is taken to avoid a mismatch between the project's stability\nlevel and the required stability and maintainability of your own project.\n\nVacuous is designed to be _small_. Its entire source code currently consists\nof 129 lines of code.\n\n## Building\n\nVacuous will ultimately be built by Fury, when it is published. In the\nmeantime, two possibilities are offered, however they are acknowledged to be\nfragile, inadequately tested, and unsuitable for anything more than\nexperimentation. They are provided only for the necessity of providing _some_\nanswer to the question, \"how can I try Vacuous?\".\n\n1. *Copy the sources into your own project*\n   \n   Read the `fury` file in the repository root to understand Vacuous's build\n   structure, dependencies and source location; the file format should be short\n   and quite intuitive. Copy the sources into a source directory in your own\n   project, then repeat (recursively) for each of the dependencies.\n\n   The sources are compiled against the latest nightly release of Scala 3.\n   There should be no problem to compile the project together with all of its\n   dependencies in a single compilation.\n\n2. *Build with [Wrath](https://github.com/propensive/wrath/)*\n\n   Wrath is a bootstrapping script for building Vacuous and other projects in\n   the absence of a fully-featured build tool. It is designed to read the `fury`\n   file in the project directory, and produce a collection of JAR files which can\n   be added to a classpath, by compiling the project and all of its dependencies,\n   including the Scala compiler itself.\n   \n   Download the latest version of\n   [`wrath`](https://github.com/propensive/wrath/releases/latest), make it\n   executable, and add it to your path, for example by copying it to\n   `/usr/local/bin/`.\n\n   Clone this repository inside an empty directory, so that the build can\n   safely make clones of repositories it depends on as _peers_ of `vacuous`.\n   Run `wrath -F` in the repository root. This will download and compile the\n   latest version of Scala, as well as all of Vacuous's dependencies.\n\n   If the build was successful, the compiled JAR files can be found in the\n   `.wrath/dist` directory.\n\n## Contributing\n\nContributors to Vacuous are welcome and encouraged. New contributors may like\nto look for issues marked\n[beginner](https://github.com/propensive/vacuous/labels/beginner).\n\nWe suggest that all contributors read the [Contributing\nGuide](/contributing.md) to make the process of contributing to Vacuous\neasier.\n\nPlease __do not__ contact project maintainers privately with questions unless\nthere is a good reason to keep them private. While it can be tempting to\nrepsond to such questions, private answers cannot be shared with a wider\naudience, and it can result in duplication of effort.\n\n## Author\n\nVacuous was designed and developed by Jon Pretty, and commercial support and\ntraining on all aspects of Scala 3 is available from [Propensive\nO\u0026Uuml;](https://propensive.com/).\n\n\n\n## Name\n\nSomething which is _vacuous_ is empty; devoid of content. _Vacuous_ provides representation for values which may be thus.\n\nIn general, Soundness project names are always chosen with some rationale,\nhowever it is usually frivolous. Each name is chosen for more for its\n_uniqueness_ and _intrigue_ than its concision or catchiness, and there is no\nbias towards names with positive or \"nice\" meanings—since many of the libraries\nperform some quite unpleasant tasks.\n\nNames should be English words, though many are obscure or archaic, and it\nshould be noted how willingly English adopts foreign words. Names are generally\nof Greek or Latin origin, and have often arrived in English via a romance\nlanguage.\n\n## Logo\n\nThe logo shows a stylized pressure gauge, reading zero.\n\n## License\n\nVacuous is copyright \u0026copy; 2025 Jon Pretty \u0026 Propensive O\u0026Uuml;, and\nis made available under the [Apache 2.0 License](/license.md).\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Fvacuous","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpropensive%2Fvacuous","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Fvacuous/lists"}