jhoxray

Joined 5 years ago

Karma
23
Submissions
12
Member since
Sep 2
Haskell, Type Theory and FP researcher
View on Hacker News

Recent submissions

Comment · 3 years ago
new tutorial with code and some interesting concepts / questions raised
Comment · 5 years ago
There shouldn't be any, as the article is not behind the paywall?
Comment · 5 years ago
very nice, thank you!
Comment · 5 years ago
Thank you, and it is about Pi and Sigma types in the end, yes. The "Entity" would likely be Pi, and the "Database" - that takes variable number of Type parameters and generalizes type classes - would be Sigma.

"DatabaseContext" should provide a low-level API to the database we want to use, so that our "Entity" or "Database" pi/sigma types generate the same API for our pure types regardless of the underlying database. Using generics, default function implementations etc.

Actually, for single-table it is quite possible even now - we can design an Entity type family that would take care of storing / retreiving flat record types in SQL or Mongo using the same API. We'd still need to pass table names explicitly though (that's where Pi types would be useful), while specific db connection would be hidden inside a monad.

What we can't do - is model relationships elegantly by using function types ("Person -> [Post]" etc) - that's where the "Database" typeclass comes in.

Comment · 5 years ago
Thank you, very good points!
Comment · 5 years ago
a bit too technical :)

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton