You must put it in the makeApplication function in the Application.hs swap file.
This function will run once for each instance of your web application that runs 1, and since you almost always use only one instance of your application, this is the place you have to make.
1 Note that it is theoretically possible to run multiple instances of the same WAI application in the same process, for example. if you want two instances to listen on different ports, but by default this will never happen.
source share