I\'ve been trying to come up with a simple and intuitive way to use databases with Haskell. I\'ve taken this code from the Yesod book and tried to clean it up so that it can
With
main = do
updateDB "Frank Silver" 40
the type of updateDB "Frank Silver" 40
is inferred to be IO ()
, since that's the default type for main
(it must have type IO a
for some a
). But from the definition, its type is inferred to be MonadRescource m => m a
for some a
(probably a = ()
, but I'm not sure), and there is no instance MonadResource IO
. So you need something to transform the updateDB
to an IO
action, the normal way to do that is runResourceT
, which transforms a ResourceT m a
into an m a
(here m = IO
), so
main = runResourceT $ updateDB "Frank Silver" 40
works.