Skip to content

Instantly share code, notes, and snippets.

@ollimandoliini
ollimandoliini / effectful-servant.md
Created August 17, 2023 11:02
effectful ♥️ servant

effectful ♥️ servant

In the Haskell world effect systems are currently a big thing and one of the most popular libraries on that front is effectful. When it comes to libries for creating webservices, the most popular one at the time of writing this is probably servant.

The two libraries go very well together but it isn't exactly obvious how you can marry them up since there doesn't seem to exist any examples at the moment. That's why I decided to create one. I'll go through setting up a simple service line by line and at the end of post I'll post the whole example. So if you're just after some quick boilerplate you can scroll right to the end.

If you haven't already, create a new project using cabal init -i. Then let's add some dependencies to our cabal file. You can probably get away with loosening most of the constraints but with those the example is guaranteed to work on ghc-9.2.7.

{-# LANGUAGE OverloadedStrings #-}
module Parser where
import Control.Monad as M
import Data.Binary (Word8)
import Data.Binary.Builder (toLazyByteString)
import qualified Data.Binary.Builder as B
import qualified Data.ByteString.Builder as BL
import qualified Data.ByteString.Lazy as L
import Data.Text (Text)
@ollimandoliini
ollimandoliini / yeah.md
Last active May 15, 2021 14:15
blog/First test post

Joujou

This is the first blog post

module Main where
-- DAY 4
import Control.Applicative hiding (some, many)
import Control.Monad
import Data.Void
import Text.Megaparsec hiding (State)
import Text.Megaparsec.Char
import qualified Text.Megaparsec.Char.Lexer as L
2020-09-17T13:03:53.455+0300 [DEBUG] plugin.terraform-provider-google_v3.38.0_x5: ---[ REQUEST ]---------------------------------------
2020-09-17T13:03:53.455+0300 [DEBUG] plugin.terraform-provider-google_v3.38.0_x5: POST /v1beta1/projects/projectname/locations/europe-west4/environments?alt=json&prettyPrint=false HTTP/1.1
2020-09-17T13:03:53.455+0300 [DEBUG] plugin.terraform-provider-google_v3.38.0_x5: Host: composer.googleapis.com
2020-09-17T13:03:53.455+0300 [DEBUG] plugin.terraform-provider-google_v3.38.0_x5: User-Agent: google-api-go-client/0.5 HashiCorp Terraform/0.13.2 (+https://www.terraform.io) Terraform Plugin SDK/1.11.0 terraform-provider-google/3.38.0
2020-09-17T13:03:53.455+0300 [DEBUG] plugin.terraform-provider-google_v3.38.0_x5: Content-Length: 95
2020-09-17T13:03:53.455+0300 [DEBUG] plugin.terraform-provider-google_v3.38.0_x5: Content-Type: application/json
2020-09-17T13:03:53.455+0300 [DEBUG] plugin.terraform-provider-google_v3.38.0_x5: X-Goog-Api-Client: gl-go/1.14.5 gdcl/20200707
2020-09-17
@ollimandoliini
ollimandoliini / me.md
Last active April 2, 2022 09:11
Olli Kortelahti

Olli Kortelahti

Olli is a freelance software engineer with a passion for functional programming and building high-quality systems. He can deliver software end to end, from mapping out user needs to deploying the solution to the cloud. He values thought-out software development processes and aims to automate everything that can be automated.

Olli can take full responsibility for his own work as well as for more junior engineers. His educational background and work experience make him an ideal match for projects involving data science and software around it.

Experience

Freelancer 2020 ->

  • Institute of Clever Stuff, 2020 -> 2022