purescript / purescript-filterable

Classes for filterable and witherable data structures
MIT License
25 stars 7 forks source link

Add Compactable class #13

Closed gabejohnson closed 6 years ago

gabejohnson commented 6 years ago

A port of https://hackage.haskell.org/package/Compactable-0.1.0.2/docs/Control-Compactable.html

Compactable doesn't require a Functor. In fact, some data types without a Functor instance can have a Compactable instance (e.g. Set).

Compactable provides compact and a method I'm currently calling separate. These are equivalent to Filterable's filtered and partitioned, respectively.

The intention with this PR is to make Compactable a superclass of Filterable.

The functions defined below the compactable instances are simply the result of adding constraints in the monad hierarchy (plus Traversable) and a few show up under different names in Filterable and Witherable with the following equivalences:

The functions that result from applying the other constraints (Apply and Bind) suggest other possible classes that could find a home in this library.

gabejohnson commented 6 years ago

@LiamGoodacre I think this is ready to look at.

LiamGoodacre commented 6 years ago

Would you also update the README with that link along side the existing Witherable link?

gabejohnson commented 6 years ago

Updated