Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/purescript/purescript-exists
Existential types as a library
https://github.com/purescript/purescript-exists
Last synced: 3 months ago
JSON representation
Existential types as a library
- Host: GitHub
- URL: https://github.com/purescript/purescript-exists
- Owner: purescript
- License: bsd-3-clause
- Created: 2014-05-13T01:01:16.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2022-11-16T15:42:55.000Z (almost 2 years ago)
- Last Synced: 2024-04-23T09:49:26.680Z (7 months ago)
- Language: PureScript
- Homepage:
- Size: 37.1 KB
- Stars: 33
- Watchers: 4
- Forks: 9
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-purescript - exists - Encodes existential types. (Essential libraries)
README
# purescript-exists
[![Latest release](http://img.shields.io/github/release/purescript/purescript-exists.svg)](https://github.com/purescript/purescript-exists/releases)
[![Build status](https://github.com/purescript/purescript-exists/workflows/CI/badge.svg?branch=master)](https://github.com/purescript/purescript-exists/actions?query=workflow%3ACI+branch%3Amaster)
[![Pursuit](https://pursuit.purescript.org/packages/purescript-exists/badge)](https://pursuit.purescript.org/packages/purescript-exists)The `Exists` type, for encoding existential types.
## Installation
```
spago install exists
```## Overview
The type `Exists f` is isomorphic to the existential type `exists a. f a`.
For example, consider the type `exists s. Tuple s (s -> Tuple s a)` which represents infinite streams of elements of type `a`.
This type can be constructed by creating a type constructor `StreamF` as follows:
```purescript
data StreamF a s = StreamF s (s -> Tuple s a)
```We can then define the type of streams using `Exists`:
```purescript
type Stream a = Exists (StreamF a)
```The `mkExists` and `runExists` functions then enable packing and unpacking of `SteamF` into/out of `Stream`.
## Documentation
Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-exists).