Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dotnetcarpenter/sanctuary-adt-matrix
Matrix that shows which Sanctuary ADT's implements which Type Classes
https://github.com/dotnetcarpenter/sanctuary-adt-matrix
sanctuary
Last synced: 4 days ago
JSON representation
Matrix that shows which Sanctuary ADT's implements which Type Classes
- Host: GitHub
- URL: https://github.com/dotnetcarpenter/sanctuary-adt-matrix
- Owner: dotnetCarpenter
- License: mit
- Created: 2021-08-16T00:13:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-17T13:41:40.000Z (over 3 years ago)
- Last Synced: 2024-11-27T20:47:39.303Z (28 days ago)
- Topics: sanctuary
- Language: JavaScript
- Homepage:
- Size: 31.3 KB
- Stars: 3
- Watchers: 4
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sanctuary ADT Matrix
[![npm](https://img.shields.io/npm/v/sanctuary-adt-matrix.svg)](https://www.npmjs.com/package/sanctuary-adt-matrix)
Usage:
```
$ npx sanctuary-adt-matrix
```| Type Class | Pair | Maybe | Either | Future |
| ------------- | ---- | ----- | ------ | ------ |
| Setoid | ✅ | ✅ | ✅ | ❌ |
| Ord | ✅ | ✅ | ✅ | ❌ |
| Semigroupoid | ✅ | ❌ | ❌ | ❌ |
| Category | ❌ | ❌ | ❌ | ❌ |
| Semigroup | ✅ | ✅ | ✅ | ❌ |
| Monoid | ❌ | ✅ | ❌ | ❌ |
| Group | ❌ | ❌ | ❌ | ❌ |
| Filterable | ❌ | ✅ | ❌ | ❌ |
| Functor | ✅ | ✅ | ✅ | ✅ |
| Bifunctor | ✅ | ❌ | ✅ | ✅ |
| Profunctor | ❌ | ❌ | ❌ | ❌ |
| Apply | ✅ | ✅ | ✅ | ✅ |
| Applicative | ❌ | ✅ | ✅ | ✅ |
| Chain | ✅ | ✅ | ✅ | ✅ |
| ChainRec | ❌ | ✅ | ✅ | ✅ |
| Monad | ❌ | ✅ | ✅ | ✅ |
| Alt | ❌ | ✅ | ✅ | ✅ |
| Plus | ❌ | ✅ | ❌ | ❌ |
| Alternative | ❌ | ✅ | ❌ | ❌ |
| Foldable | ✅ | ✅ | ✅ | ❌ |
| Traversable | ✅ | ✅ | ✅ | ❌ |
| Extend | ✅ | ✅ | ✅ | ❌ |
| Comonad | ✅ | ❌ | ❌ | ❌ |
| Contravariant | ❌ | ❌ | ❌ | ❌ |## Using the matrix API
Test [Sanctuary's](https://sanctuary.js.org/) Algebraic Data Types (ADT) for [Type Class](https://github.com/sanctuary-js/sanctuary-type-classes/tree/v12.1.0#sanctuary-type-classes) support.
> The API is **unstable** and will probably change between minor versions.
```js
const { adts, typeClassTests } = require ('sanctuary-adt-matrix');// adts :: Array (Array (String Adt))
[
['Pair' , Adt],
['Maybe' , Adt],
['Either', Adt],
['Future', Adt]
]// typeClassTests :: Array (Array (String Adt) -> Array (String))
typeClassTests [0] (adts) // -> [ 'Setoid', '✅', '✅', '✅', '❌' ]
```## Adding an ADT
Currently (1.0.1), you need to change two places. To add a new ADT, you need to edit _index.js_,
require the new ADT and add it to the `adts` array.```js
const adts = [
['Pair' , S.Pair ('') ('')],
['Maybe' , S.Just ('')],
['Either', S.Right ('')],
['Future', Future (reject => resolve => () => {})]
];
```
_The tuple is `[name:String, instance:ADT]`._Then you need to set padding in _view/markdown.js_ in the `view` function.
```js
${S.joinWith ('\n')
(S.map (r => `| ${r} |`)
(row ([13, 3, 4, 5, 5]) (S.map (test => test (adts))
(typeClassTests))))}
```
_The padding is `[13, 3, 4, 5, 5]`._```js
[
13, // = longest Type Class word
3, // = padding for Pair column
4, // = padding for Maybe column
5, // = padding for Either column
5, // = padding for Future column
// add padding for your ADT column - usually number of characters minus 1
]
```