Skip to content

Instantly share code, notes, and snippets.

@christian-marie
Created June 25, 2015 00:46
Show Gist options
  • Save christian-marie/899cf49873078d3a59cd to your computer and use it in GitHub Desktop.
Save christian-marie/899cf49873078d3a59cd to your computer and use it in GitHub Desktop.
20:27 < simon> does anyone have an example use of resource-pool?
20:28 < simon> and since I plan to use it with MySQL, should I be using the groundhog-mysql package?
20:32 < simon> wait, never mind about the last part. groundhog seems cool, but not sure I really want it right now.
20:44 < bitraten> simon: https://github.com/bitraten/bitrest/blob/master/src/Database.hs
20:47 < bitraten> In most cases you can ignore the IORef and just use a Reader
20:50 -!- rodlogic [~rodlogic@c-71-234-52-85.hsd1.ct.comcast.net] has quit [Remote host closed the connection]
21:00 < simon> bitraten, thanks!
21:10 < alpounet> simon: the simplest solution is probably to just make your Server a function that takes a 'Pool Connection' as argument
21:10 < alpounet> server :: Pool Connection -> Server YourAPI ; server pool = endpoint1 :<|> endpoint2 :<L> endpoint3 ...
21:11 < alpounet> and each request handler can use the pool
21:11 < alpounet> if they pretty much all do you can use a Reader or something
21:11 < alpounet> it's covered here in the tutorial, fwiw: https://haskell-servant.github.io/tutorial/server.html#using-another-monad-for-your-handlers
21:36 < simon> alpounet, that's what I did so far. I'm going to wrap it in a ReaderT, though.
21:36 < simon> alpounet, thanks for the link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment