Great! Feel free to ask questions if you get stuck. Everything makes
perfect sense to *me*, so getting user feedback is crucial for
figuring out what needs better documentation.
The types for clientsession are a bit intense. We are moving towards
building another layer on top of happstack, but we are not quite there
yet.
the ServerPart monad is lightweight -- and easy to use, but does not
do much. Then we have optional packages like clientsession which can
be combined together to add more power. But keeping things flexible
means more complex types.
The next thing to do is to build a 'fat' monad on top of of the
low-level pieces that ties everything together and gives you back a
nice simple type signature again. For example, we might have a
'happstack-heavy' package, which contains simple type signatures the
way 'happstack-lite' does. But 'happstack-heavy' would include things
like sessions out of the box. The tradeoff is that you get less
flexibility. But, the payoff is that someone already picked the 'best
choices' for you, and wrapped everything up into a simple package.
I think that is pretty valuable -- because having your choice of
solutions is useless if you are not qualified to evaluate what you
need. Better to have someone pick a bunch of reasonable defaults for
you. Later, you can change components if you realize that something
else really would work better in your case.
Regarding acid-state and ReaderT, you should check out this section of
the crash course when you are ready:
http://www.happstack.com/docs/crashcourse/AcidState.html#acid-state-advanced
That section actually solves the problem of being able to access
multiple acid-state handles transparently, but it works just as well
for a single acid-state handle.
You will notice in that section that I combine the ServerPartT and
ReaderT monads. But to keep my type signatures from going insane, I
wrap them inside a newtype, 'App' which automatically derives all the
same instances as ServerPart. In addition to keeping the types simple,
that alsomeans that we don't have to use 'lift' or anything fancy to
call normal Happstack functions.
I find that newtypes make using monad transformers pretty painless and
transparent. The only horrid part is the one line of code where you
have to unwrap the newtype and flatten all the monad transformers.
But, fortunately, you only have to write that once-per-app.
The unwritten Part II of the crash course will cover a bunch of 'best
practices' topics like this. Part I discusses how to use the parts in
isolation -- but combining them in a sensible manner is a whole other
skill.
- jeremy
> --
> You received this message because you are subscribed to the Google Groups
> "HAppS" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/happs/-/1j-8CjRpyUcJ.