{"id":16965055,"url":"https://github.com/propensive/anticipation","last_synced_at":"2025-04-11T23:04:31.371Z","repository":{"id":80754900,"uuid":"388416209","full_name":"propensive/anticipation","owner":"propensive","description":"Minimal typeclass definitions for seamless integration without hard dependencies for Scala","archived":false,"fork":false,"pushed_at":"2025-02-12T19:04:45.000Z","size":3326,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-20T01:38:45.122Z","etag":null,"topics":["css","dependencies","html","http","interfaces","scala","seamless","time","typeclasses"],"latest_commit_sha":null,"homepage":"https://soundness.dev/anticipation/","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":"2021-07-22T10:07:14.000Z","updated_at":"2025-02-12T19:04:49.000Z","dependencies_parsed_at":"2023-11-16T09:25:17.572Z","dependency_job_id":"59a20c60-d037-4ed0-9a7a-1baa5ac6ee72","html_url":"https://github.com/propensive/anticipation","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fanticipation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fanticipation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fanticipation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/propensive%2Fanticipation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/propensive","download_url":"https://codeload.github.com/propensive/anticipation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239805890,"owners_count":19700204,"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":["css","dependencies","html","http","interfaces","scala","seamless","time","typeclasses"],"created_at":"2024-10-13T23:44:54.900Z","updated_at":"2025-02-20T08:31:39.715Z","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/anticipation/main.yml?style=for-the-badge\" height=\"24\"\u003e](https://github.com/propensive/anticipation/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# Anticipation\n\n__Seamless integration with minimalistic typeclass interfaces foreseen__\n\n__Anticipation__ provides minimalistic typeclass interfaces to absolve end users\nof the need for cumbersome dependencies between unrelated projects.\n\n## Features\n\n- minimalistic typeclass interfaces\n- integration typeclasses for HTTP, HTML and CSS\n- used by [Honeycomb](https://github.com/propensive/honeycomb/), [Cataclysm](https://github.com/propensive/cataclysm/) and [Scintillate](https://github.com/propensive/scintillate/)\n- avoids dependencies in either direction between typeclass users and providers\n\n\n## Availability\n\nAnticipation 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 Anticipation.\n\nSubsequently, Anticipation 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__Anticipation__ defines several typeclass interfaces to provide interoperability\nbetween different libraries, without requiring a hard dependency between them.\n\n### The Problem\n\nConsider a library _J_ which defines a JSON datatype, and a second library _H_\nwhich can return a different datatypes as HTTP responses. Neither library\nfundamentally requires the other, and users should be able to choose whether to\ndepend on J or H or both.\n\nBut it would nevertheless be useful for users of both J and H to be able to\nreturn JSON HTTP responses. The JSON HTTP typeclass instance must depend on\nboth J and H, which means that either,\n1. the typeclass instance is defined in J, and J depends on H\n2. the typeclass instance is defined in H, and H depends on J\n3. a new module which depends on both J and H should be created\n\nOptions 1 and 2 require a dependency—in some direction—between J and H. And\noption 3 has the disadvantage that it creates another dependency for users to\nmanage, both at the source-code and the build level.\n\nThe typeclass instance will have a type which looks something akin to\n`Http[Json]`, where `Json` is defined in J and `Http` is defined in H. That\nfurthermore precludes the possibility that the given instance could be defined\nin the companion objects of either of those types.\n\nIdeally, users should be able to add both J and H (independently) to their\nbuild, and import no more than the packages of J and H, and automatically get\naccess to the integration typeclass instance without any further work.\n\nThis is what Anticipation provides.\n\n### The Solution\n\nThe issues above can be circumvented by predefining a set of minimalistic\ntypeclass interfaces for each integration point necessary, and having each\nlibrary independently depend upon them.\n\nAs much as possible, the typeclass interfaces should not require any additional\ndatatypes to be defined; they should depend only on types in the standard\nlibrary. Whilst this may compromise the utility of these typeclasses, they are\nintended to be used only by the integration libraries; not by end-users.\n\nContinuing the earlier example, the libraries J and H could both depend on\nAnticipation. J would then define a typeclass instance for its JSON type in its\ncompanion object, and H would define a typeclass converter from Anticipation's\ntypeclass to its own user-facing typeclass interface in its companion object.\n\nConsequently, users of both H and J could depend on both libraries, import both\npackages (and nothing more) and automatically be able to use the integration\nbetween them.\n\n### Anticipation Typeclasses\n\n#### `GenericCssSelection` in the `css` module\n\nUsed primarily by [Cataclysm](https://github.com/propensive/cataclysm/), this\nallows different types to be used in CSS selectors. Implementations are\nprovided in [Honeycomb](https://github.com/propensive/honeycomb/) for its\nrepresentations of CSS class names (`honeycomb.Cls`), DOM IDs\n(`honeycomb.DomId`), and HTML tags (`honeycomb.TagType`).\n\n#### Paths, Files and Directories in the `file` module\n\nSix typeclass interfaces provide the ability to read and write representations\nof paths, files and directories. These are used by projects such as\n[Surveillance](https://github.com/propensive/surveillance/),\n[Oubliette](https://github.com/propensive/oubliette/),\n[Rudiments](https://github.com/propensive/rudiments/),\n[Imperial](https://github.com/propensive/imperial/) and\n[Guillotine](https://github.com/propensive/guillotine/) to support interaction\nwith any library which provides path-like types.\n[Galilei](https://github.com/propensive/galilei/) provides instances for its\n`galilei.Path`, `galilei.File` and `galilei.Directory` types, and\n[Diuretic](https://github.com/propensive/diuretic/) provides instances for\ntypes in the Java standard library, such as `java.io.File` and\n`java.nio.file.Path`.\n\nThe typeclasses are called,\n- `GenericPathReader`\n- `GenericFileReader`\n- `GenericDirectoryReader`\n- `GenericPathMaker`\n- `GenericFileMaker`\n- `GenericDirectoryMaker`\n\nIn a later version of Anticipation, each `Reader` and `Maker` pair may be\ncombined into a single typeclass.\n\n#### `GenericHtmlAttribute` in the `html` module\n\nAn HTML library, most notably\n[Honeycomb](https://github.com/propensive/honeycomb/), can support attributes\nhaving typed values (rather than just strings), provided that type is suitable\nfor the given attribute. The `GenericHtmlAttribute` typeclass, parameterised on\nthe singleton literal type of the attribute name, and the value type, allows\nlibraries to make their types usable in such HTML libraries.\n[Gesticulate](https://github.com/propensive/gesticulate/) makes\n`gesticulate.MediaType`s usable for `formenctype`, `enctype`, `media` and\n`type` attributes. [Scintillate](https://github.com/propensive/scintillate/)\nallows `scintillate.RequestParam` instances to be used for the `name` parameter\nof inputs in a form. [Cataclysm](https://github.com/propensive/cataclysm/)\nsupports `cataclysm.CssStyle` values to be used on an HTML tag's `style`\nattribute. And [Serpentine](https://github.com/propensive/serpentine/) and\n[Telekinesis](https://github.com/propensive/telekinesis/) allow\n`serpentine.Relative`, `serpentine.GenericPath`, `telekinesis.HttpMethod` and\n`telekinesis.Url` instances to be used in the variety of attributes which\nsupport these types, such as `src`.\n\n#### `GenericHttpResponseStream` and `GenericHttpReader` in the `http` module\n\nThese typeclasses provide support for working with various types over HTTP. Any\ntype which can be streamed to HTTP, including an appropriate media type, can be\nfurnished with a `GenericHttpResponseStream` instance. Libraries which provide\nthese types include:\n\n- [Caesura](https://github.com/propensive/caesura/), for `caesura.Csv` and `caesura.Tsv` types\n- [Cataclysm](https://github.com/propensive/cataclysm/), for `cataclysm.CssStylesheet`s\n- [Honeycomb](https://github.com/propensive/honeycomb/), for `honeycomb.HtmlDoc`s\n- [Jacinta](https://github.com/propensive/jacinta/), for `Json` values\n- [Xylophone](https://github.com/propensive/xylophone/), for `Xml` values\n\nA `GenericHttpReader` instance is provided in\n[Jacinta](https://github.com/propensive/jacinta/) for reading a `Json` value\ndirectly from an HTTP response.\n\n#### `GenericInstant` and `GenericDuration` in the `time` module\n\nAny library which needs to work with time values, as instantaneous points in\ntime or as time durations, should use `GenericInstant` or `GenericDuration`\nrespectively.  [Parasite](https://github.com/propensive/parasite/) and\n[Turbulence](https://github.com/propensive/turbulence/) use these typeclasses\nfor generic time-related operations, and instances are provided for Java types\nin [Diuretic](https://github.com/propensive/diuretic/) and\n[Aviation](https://github.com/propensive/aviation/) for `aviation.Instant` and\n`aviation.Duration` types.\n\n#### `GenericUrl` in the `url` module\n\nMany libraries need to work with URLs, and the `GenericUrl` provides a generic\ninterface that's use by [Tarantula](https://github.com/propensive/tarantula/)\nand [Telekinesis](https://github.com/propensive/telekinesis/).\n[Diuretic](https://github.com/propensive/diuretic/) provides instances for\n`java.net.URL` and Telekinesis provides an instance for its own\n`telekinesis.Url` type.\n\n\n\n\n\n\n## Status\n\nAnticipation 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\nAnticipation is designed to be _small_. Its entire source code currently consists\nof 319 lines of code.\n\n## Building\n\nAnticipation 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 Anticipation?\".\n\n1. *Copy the sources into your own project*\n   \n   Read the `fury` file in the repository root to understand Anticipation'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 Anticipation 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 `anticipation`.\n   Run `wrath -F` in the repository root. This will download and compile the\n   latest version of Scala, as well as all of Anticipation'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 Anticipation are welcome and encouraged. New contributors may like\nto look for issues marked\n[beginner](https://github.com/propensive/anticipation/labels/beginner).\n\nWe suggest that all contributors read the [Contributing\nGuide](/contributing.md) to make the process of contributing to Anticipation\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\nAnticipation 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\nAnticipation is the consideration of something before it happens, and _Anticipation_ provides typeclass definitions in expectation of\ntheir future implementation.\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 simple floral pattern.\n\n## License\n\nAnticipation 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%2Fanticipation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpropensive%2Fanticipation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpropensive%2Fanticipation/lists"}