allow passing a function to `p.transaction`

TODO: document this