Write PostgreSQL functions in Haskell