Do your taxes with Haskell!

It’s that time of the year again, but now I got ready.

The last year’s debut of the canadian-income-tax package came rather late in the tax season, because I only realized it was possible when I went to do my own taxes. I had a year to prepare since then, so you can use the just-released version 2023.0 now, 2023 signifying the tax year it’s for. But it’s not only the tax year that’s different!

  • I learned that different provinces’ T1 forms only look the same, but are actually different PDFs with subtle differences in field coding carefully designed to make a programmer’s life miserable. My stubborn perfectionist streak made me handle them all. Every single province and territory. I hope there’s a Haskeller in Nunavut who can appreciate what I went through.
  • The last year’s release supported the 428 provincial tax form only for Ontario. This year I added support for the 428 forms for Alberta, British Columbia, and Manitoba. Then I stopped. There’s a limit to everything.
  • There’s also the 479 provincal tax credit form, for Ontario and British Columbia only.
  • The federal schedule forms 6, 7, 9, and 11 are supported as well. Thankfully they’re the same for all provinces.
  • Given a large number of possible options, the command line has been redesigned.
  • I also added a tiny web server with interactive UI if that’s your thing.

So there you go Haskell-Canadians. You have no excuse to delay your tax returns any more.

17 Likes

I’d love to do the same with spanish taxes… But I think its complexity is beyond turing completeness

2 Likes

I would not exclude the possibility that the situation is even worse — that the tax code is logically inconsistent; i.e. that you have to pay both, say, 30% tax and 32% tax at the same time.

4 Likes

That’s why the project is limited to handle only the boring, deterministically computable parts of the tax return. The creative parts are up to the user. The breakthrough was when I realized that the two parts could be easily separated.

1 Like

People might be interested in the fact that a significant chunk of the french tax code has been formalised in Catala, and some of the US tax code too.

2 Likes

Over here in Germany, we’ve been doing our taxes with Haskell since 2020. Henning Thielemann has been helping us to file a particular type of tax in Germany that is provably unsolvable (a huge system of linear equations with more unknowns than equations, but the tax depends on the solution) and has released a number of Haskell packages during development. He even found and reported bugs in upstream C libraries he was writing FFI bindings for. It was fun to find the minimal example where the tax problem becomes underspecified. The ministry of economics has been informed, but strangely they don’t seem to want to know their law is defunct.

7 Likes

Public Service Announcement

I have started hosting the service at taxell.ca for anybody who could use it but couldn’t build and install the project from source.

4 Likes

While we’re at it, here’s my tax-ato library for Australian individual income taxes: Data.Tax.ATO.

You can’t use it to submit your tax return (perhaps one day…), but I find it useful for estimating and preparing my taxes. It is far from complete and has some known bugs. If you are interested to try it out but hit a gap, please file an issue or send a PR. I plan to continue improving and extending (and better documenting!) the library over time.

1 Like