Re:Simplify Your Code: Functional Core, Imperative Shell
by shortrounddev2 on Tuesday October 28, 2025 @10:56AM
(#45733690)
In linq (C#)
Such simple logical expressions (called expression trees) get converted to SQL queries
[ Parent
| on HN ]
Re:Simplify Your Code: Functional Core, Imperative Shell
by ryanrasti on Tuesday October 28, 2025 @01:21PM
(#45735819)
The is exactly the way forward: encapsulation (the function), type safety, and dynamic/lazy query construction.
I'm building a new project, Typegres, on this same philosophy for the modern web stack (TypeScript/PostgreSQL).
We can take your example a step further and blur the lines between database columns and computed business logic, building the "functional core" right in the model:
// This method compiles directly to a SQL expression
class User extends db.User {
isExpired() {
return this.expiresAt.lt(now());
}
}
const expired = await User.where((u) => u.isExpired());
Here's the playground if that looks interesting: https://typegres.com/play/
Re:Simplify Your Code: Functional Core, Imperative Shell
by quails8mydog on Thursday October 30, 2025 @05:45PM
(#45765760)
And anyone who calls that method may find themselves dealing with the implementation details of Entity Framework and whatever db provider you're using because it's a leaky abstraction.