HasX classes for all snaplets
Closed this issue · 1 comments
mikeplus64 commented
For consistency and convenience, just as there is a HasHeist class, there should be classes for all snaplets, ie
-- I'm not sure if SnapletLens should be used, or why it's used at all.
class HasSession b where
sessionLens :: Lens' b (Snaplet SessionManager)
class HasAuth b where
authLens :: Lens' b (Snaplet (AuthManager b))
mightybyte commented
One of the general design principles we've taken with the Snap Framework as a whole is to minimize our use of type classes. A type class is essentially global state with information for a specific type. A design built around a HasAuth type class is implicitly saying that there can only be one method of auth for the type b. This made sense for Heist, but does not make sense for sessions and auth. It is easy to imagine situations where one would want more than one form of sessions or authentication, so we deliberately chose to not use type classes in these cases.