Rest-ish Services in Haskell Part 3
tl;dr - In this post I work my way through sprinkling in some DataKinds (shoutout to dcasto’s excellent primer), abstracting the TaskStore into an EntityStore, and adding servant to actually expose this EntityStore via an well-typed TodoAPI over HTTP. We actually get to a running server in this post, finally! Multi-part blog post alert This is a multi part blog post with the following sections:
REST-ish Services in Haskell: Part 2
tl;dr - Work our way through some more type tomfoolery, domain modeling (w/ a light discussion of Domain Driven Design). Next a Component which can operate on the Task domain model, the TaskStore is introduced. Then the types “hit the road” and we build a partial implementation of a SQLiteTaskStore (with assistance from sqlite-simple). The code is available in the haskell-restish-todo repo, @ tag part-2.
REST-ish Services in Haskell: Part 1
tl;dr - A general tour through a bunch of patterns/strategies I use when developing robust-ish REST-ish web services with Haskell. This post boils down to using some approaches to getting creature comforts set up for your binary. If you want to go straight to the code, check out the gitlab repo @ tag part-1 UPDATE (11/28/2018) One of the great thing about blog posts is getting feedback and thanks to Magnus over @ therning.
Kicking The Tires On Fathom
tl;dr - I set up Fathom for an application running in my small kubernetes cluster. It was easy but required a little hackery to properly init fathom (in particular creating the root user) Recently I came across Fathom (usefathom/fathom on github) thanks to restoreprivacy.com’s google-alternatives page. They also got posted on Hacker News, which was cool to see. Up until now I’ve been using Matomo (formerly Piwik) for my website analytics (for example on this blog) – it’s got a bucketload of features and is relatively easy to setup along with having some good defaults.
Adding a very naive in-memory cache to my Haskell web app
tl;dr - I added some caching to an app I’m writing in Haskell using Servant. The implementation is pretty naive, but I’ve seen some speedups (as one would expect from skipping a database access), and am glad I was able to build such a simple solution in a language as expressive as haskell. Skip to the end TLDR section to see all the code laid out! FAIR WARNING - this will is NOT an interesting article about caching algorithms or a quirk in GHC or optimization strategies.
Adding Sqlite Powered Fts Search To A Servant Powered Haskell App
tl;dr - You may not need a big robust beautifully crafted DB like Postgres every time you build an app. Sometimes SQlite is probably enough. SQLite even provides Full Text Search addons in the way of FTS3/4 and FTS5, so that’s cool too – skim through the article for code snippets on the why/how I’m using SQLite + FTS3/4. If you’re unfamiliar with SQLite, it’s a pretty awesome light-weight SQL-compliant RDBMS.
Within seconds of using Pingdom I got email spam
tl;dr - I do a web speed test on this site, get spam from a firm that does website speed consulting, I rant a little bit about it, then share a little bit about a startup idea I had at the end. I’ll be back to regular “exploring Kubernetes” related posts tomorrow! So this just happened (<5 minutes ago), but within seconds of heading over to Pingdom’s Speed test (I was really trying to test Piwik tracking on this blog), I got an email from some firm called SpeedUpgency that I’ve never heard of:
Setting Up SSL Certs on Kubernetes
tl;dr - letsencrypt is awesome, ployst/docker-letsencrypt makes it easy to use with Kubernetes (feel free to check out the blog post that describes it). There are even easier ways to do it these days that I haven’t tried: kube-lego which looks pretty amazing. After going through figuring out how to run HTTP applications on Kubernetes, as well as how to run databases on Kubernetes, the next natural step is to figure out how to gear up to running HTTPS applications on Kubernetes.
Stop Using React
tl;dr The BSD + PATENTS.md pattern is not F/OSS. Facebook is trying to goad you into entering a mutually assured destruction patent stalemate, but you don’t have nukes. They do. Stop using React, there are other better alternatives. Before you get into my thoughts, maybe you’ll want to look at some other debate from other strangers on the internet: Discussion of Facebook’s explanation on HN Discussion on Apache Foundation banning use of React on Reddit
Adding A Merge Patch Content Type To Servant
*tl;dr See the code at the end Very often when developing a web application I run into the age-old problem of how to do partial updates. Doing the “U” (Update) in CRUD is actually a little more complicated than just accepting PUTs at some endpoint if you dont’ want to replace the object as a whole. I’ve often worked around this while maintaining somewhere-near spec complicance by just using the catch-all that is POST, and taking whatever object represented the update and doing whatever needed to be done.