[Haskell-cafe] getRandom in HAppS-State (Was: ANNOUNCE: gitit 0.2
release)
Joachim Breitner
mail at joachim-breitner.de
Sun Nov 30 15:36:31 EST 2008
[Re-sending to the list, sorry for the doubled mail, John]
Hi John,
Am Samstag, den 08.11.2008, 12:32 -0800 schrieb John MacFarlane:
> I've uploaded an early version of gitit, a Haskell wiki program, to
> HackageDB. Gitit uses HAppS as a webserver, git for file storage,
> pandoc for rendering the (markdown) pages, and highlighting-kate for
> highlighted source code.
looking through your code, I see this:
newSession :: (MonadState AppState (Ev (t GHC.Conc.STM)), MonadTrans t,
Monad (t GHC.Conc.STM)) =>
SessionData -> Ev (t GHC.Conc.STM) SessionKey
newSession u = do
key <- getRandom
setSession key u
return key
for a project of mine, I had so solve a similar problem, and first I
used this way, but I’m wondering: The event is serialized without the
random seed (I think), so when your app crashes and the event log is
re-done, you might get a different key? Or does is getRandom function
somehow deterministical?
My solution was to pass a RNG into my function:
> addNewIssue :: MonadState State m => StdGen -> m Issue
and then use
> gen <- liftIO $ newStdGen
> i <- update $ AddNewIssue gen
But maybe I’m worring too much... what do you think?
Greetings,
Joachim
--
Joachim "nomeata" Breitner
mail: mail at joachim-breitner.de | ICQ# 74513189 | GPG-Key: 4743206C
JID: nomeata at joachim-breitner.de | http://www.joachim-breitner.de/
Debian Developer: nomeata at debian.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20081130/30c42482/attachment.bin
More information about the Haskell-Cafe
mailing list