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 | ❌ | ❌ | ❌ | ❌ |
Test Sanctuary's Algebraic Data Types (ADT) for Type Class support.
The API is unstable and will probably change between minor versions.
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', '✅', '✅', '✅', '❌' ]
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.
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.
${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]
.
[
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
]