snapframework / snap

Top-level package for the official Snap Framework libraries, includes the snaplets API as well as infrastructure for sessions, auth, and templates.
http://snapframework.com/
BSD 3-Clause "New" or "Revised" License
455 stars 68 forks source link

MonadReader instance for Handler #75

Closed hesselink closed 11 years ago

hesselink commented 11 years ago

The Snap.Snaplet.Handler type has a MonadState instance, but no MonadReader instance. Is there a good reason for this, or can one be added? I could send a pull request if you want.

mightybyte commented 11 years ago

I assume you're talking about a MonadReader instance like this?

instance MonadReader v (Handler b v)

If that's the case, I'm not really inclined to add that instance since it duplicates the functionality provided by the MonadState instance. Although I suppose it would be useful if you're interacting with some other library that needs a MonadReader. Is that your use case?

hesselink commented 11 years ago

Yes, exactly. I have functions generalized over MonadReader, which I can't use in a Handler currently. Since every MonadState is trivially a MonadReader (through ask = get and a slightly more convoluted local definition), it seems like there are not many downsides. And StateT itself also has a MonadReader instance.

mightybyte commented 11 years ago

Ok, you convinced me. The fix is in commit 7a5f14bc2597583978404c3f84281320b1763d91.

hesselink commented 11 years ago

Thanks!