purescript / purescript-profunctor

Profunctor type classes and data structures
BSD 3-Clause "New" or "Revised" License
33 stars 13 forks source link

New classes: Closed, Costrong and Cochoice #13

Closed zrho closed 8 years ago

zrho commented 8 years ago

There are three types of profunctors this library has been missing out on, which can be quite useful in the profunctor-lens library:

Closed is used for implementing Grates (http://r6research.livejournal.com/28050.html), which are an optic generalizing zipping of representable functors. Costrong and Cochoice can be used to implement a function re that not only reverses Isos, but is also able to e.g. reverse a Prism to a Getter.

Since purescript is not lazy, the instances for Cochoice and Costrong found in the Haskell analog of this library unfortunately can not work. Forget and Tagged, however, are instances of Cochoice and Costrong, respectively. Maybe we should add them, too; with a more descriptive name perhaps?

paf31 commented 8 years ago

Looks great (grate?), thanks. I'm curious about the re function, I still haven't fully grokked how that will work, although I sort of see how something like Costrong identifies a product relationship between two types, like Strong does in the opposite direction.