robrix / freer-cofreer

freer monads and cofreer comonads.
BSD 3-Clause "New" or "Revised" License
21 stars 1 forks source link

Optimizable Freer #8

Open robrix opened 7 years ago

robrix commented 7 years ago

This PR defines Map and Seq constructors for Freer in an attempt to enable optimization by analyzing subsequent values.

A few of the mechanisms operating over Seq are defined by rewriting the Seq as a Then; this includes the Traversable instance (because this would require splitting the Seq up into separate values, necessarily parameterized by different types), and also project & therefore iterFreer. Unfortunately, this means that sequenceA . sequenceA /= id (which in fairness is generally the case, e.g. for Maybe), project . embed /= id, &c.

robrix commented 7 years ago

cc @tclem