Series Spotlight: Haskell Web Skills!

Haskell has a reputation of being a neat language with cool concepts used a lot in academic research. But the dark side of this reputation is that people imagine it's unsuited for production use. But nothing could be further from the truth!

A common misconception about Haskell is that it “doesn’t have side effects.” Of course any language needs to have side effects to be effective. What makes Haskell unique isn’t that it doesn’t have side effects at all. What makes it unique (or at least uncommon) is that you have to encode side effects within the type system. This means you can know at compile time where the effects lie in your system.

To get a feel for how you can write normal programs with Haskell, you should read our Haskell Web Series. It will take you through the basics of building a simple web application using Haskell. We’ll highlight a couple specific libraries that allow you to do common web tasks.

In part 1, we’ll use the Persistent library to connect to a Postgresql database. This involves using a more complex concept called Template Haskell to create our database schema. That way, we can automatically generate the SQL statements we need.

In part 2, we’ll learn how to use the Servant library to create an HTTP server. We’ll also see how we can connect it to our database and make requests from there.

Next, we’ll use the Hedis library to connect to Redis. This will allow us to cache some of our database information. Then when we need it again, we won't have to go to our database!

Part 4 covers how we test such a complicated system. We’ll also see how to use Stack to connect our system with Docker so that our side services are easy to manage.

Finally, we wrap this series up in part 5, where we’ll look at some more complicated database queries we can make. This will require learning another library called Esqueleto. This cool library works in tandem with Persistent.

There are a lot of different libraries involved in this series. So it’s essential you know how to bring outside code into your Haskell application. To learn more about package management, you should also take our free Stack mini-course. It’ll help you learn how to create a real Haskell program and connect to libraries with ease.

And if you’ve never written Haskell before, now’s a great time to start! Download our Beginner’s Checklist for some tips!