You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I have a colleague learning Haskell and Servant and they were following this guide as a template and they copied use of unsafe{Perform,Interleave}IO for the global variable and it got me thinking this may be the wrong message to be sending to people using owlcloud to learn. Its pretty easy to throw the TVar in a Reader and initialize it in IO in Main. I haven't checked how much work it would be but would you take a PR to eliminate this global?
The text was updated successfully, but these errors were encountered:
@MichaelXavier at the time of writing the article I decided to go with the global variable, probably because at the time I saw it clearly that otherwise, it'd distract the reader. So, a short answer is – it depends on how PR would look like. I'm definitely not against it, but I think it might indeed turn out to be a bit of a monad transformer tutorial which I wouldn't want it to become.
Alternatively, we could just pass the db explicitly everywhere in params where it's needed, maybe that'd be better? I don't remember if I checked this theory.
PR showing any of those you decide is better is highly appreciated and I'd review it from a point of all possible things which would make it acceptable.
@k-bx my initial approach was going to be a ReaderT because that's always my go to for in-memory RO state for web apps, but I see your concerns since monad transformers are a somewhat advanced (but critical IMO) concept. I guess I'd also argue that justified use of unsafe functions is also pretty advanced so you can expect newbies to be copy/pasting without understanding in both cases.
Still, if I do take a crack at this I'll try with explicit argument passing first given your concerns. Everyone can understand that and if it works out, maybe we could just comment that the approach could be tidied up with a Reader.
Hi! I have a colleague learning Haskell and Servant and they were following this guide as a template and they copied use of
unsafe{Perform,Interleave}IO
for the global variable and it got me thinking this may be the wrong message to be sending to people using owlcloud to learn. Its pretty easy to throw the TVar in a Reader and initialize it in IO in Main. I haven't checked how much work it would be but would you take a PR to eliminate this global?The text was updated successfully, but these errors were encountered: