Seeking advice on which Haskell back end frameworks/libraries to use

Hi everyone, I’m currently developing a web application that runs Elm client side and Python (Flask) on the server. I’ve been using type hints and an algebraic data type module in Python to try and maintain some of the type safety that I have in Elm, but it’s getting a bit ridiculous now and is a bit of a burden to maintain. I’ve decided that I should just make the leap and move the back end over to Haskell. There are a lot of choices for libraries, so I was hoping that people might be able to point me in the right direction.

If anyone has any advice on the following, it’d be very much appreciated:

  1. A library for managing WebSockets.
  2. A GraphQL library.
  3. A database ORM, or some sort of persistence, it’s early enough in the project that I can change this. I’m currently using SQLAlchemy with SQLite. I’d prefer not to write SQL queries by hand.

Also any more general comments about using Haskell with Elm would be welcome too!

3 Likes

Have you tried Python’s FastAPI? It claims to be pretty strong about static typing:

“FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.” Source: https://fastapi.tiangolo.com/

You can use mypy or pyright from MS for static type checking, and pyright has even type inference!

For Haskell, you might get inspiration from the Real World App implemented in Haskell, with 3 variants (Yesod, Scotty, Servant):

3 Likes

I did have FastAPI recommended to me a while back, but it seems to have come on a lot since then. Thanks, I’ll take a look at that.

I haven’t looked at RWAs for Haskell back ends, although those are the three frameworks that I’ve spent most time looking at. I found Scotty to be the easiest to work with, but it’s difficult to envisage how these things scale. Hopefully RWAs will give me a bit of insight into that!

Thanks for you suggestions, they’re much appreciated!

1 Like

I cannot recommend libraries for Haskell backends from production experience, but I spent a bit time the last weeks figuring the same thing out for me.

For me the most interesting web framework seems to be servant since it has great docs and seems to be rather complete for API development. It is also a nice gimmick that it can automatically generate Elm decoder / encoder for your API.

For the database I tried out HDBC and yeshql, since I need access to a weird database through odbc with a custom SQL dialect. I think I remember hearing good things about https://hackage.haskell.org/package/hasql when you’re using postgresql… Although these options are not ORMs.

Since I probably wouldn’t use GraphQL with servant, I haven’t explored this, but https://morpheusgraphql.com/ looks really interesting, just in case you haven’t seen it yet.

1 Like

Hi @ChrisWellsWood, I have recently stumbled upon Mu-Haskell and after reading through the documentation I cannot wait to give it a try!

I have not used it yet though so I cannot recommend it from experience.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.