SamuelSchlesinger / commander-cli

A simple library I wrote to allow me to quickly and easily construct command line interfaces.
MIT License
29 stars 2 forks source link

hoist not documented #14

Closed BebeSparkelSparkel closed 1 year ago

BebeSparkelSparkel commented 3 years ago

I do not see any usage of hoist. It would be nice to have some documentation of its usage in the README.

SamuelSchlesinger commented 3 years ago

That's a good point. Not going to do it tonight, because I'm about to go to the grocery store, but I do have time to give a vague idea: there are many times we want to run in a monad stack which is not IO, and we have some context that we can supply to map our ProgramT to IO from a richer monad in which its more pleasant to write our CLI app in. In particular, it might be a reader of some dynamic context or settings, for instance database connection pool and configuration.

SamuelSchlesinger commented 3 years ago

An example is that we might have ReaderT (Pool Connection) IO as the monad we'd like to use, and with a Pool Connection called p, we can create a function to pass to hoist with flip runReaderT p.

BebeSparkelSparkel commented 3 years ago

I see. Reader could be very useful here. Looking forward to seeing what you come up with.