TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Why is there no database with a functional query language?

5 pointsby fragile_frogsabout 2 years ago
I have been asking this myself for a while now, I generally do enjoy writing SQL, but I also get the feeling that it&#x27;s not suitable for building applications.<p>So why is there no &quot;functional&quot; query language? Something like Haskell, but for databases. You would get the benefits of a declarative model, composeability and type-safety.<p>I am currently using sqlx[1] and it&#x27;s great in terms of type-safety, but you can&#x27;t compose queries. I don&#x27;t like to use ORM&#x27;s, they are usually good for simple things, but hard things are impossible and you have to use&#x2F;understand SQL anyways.<p>[1] https:&#x2F;&#x2F;github.com&#x2F;launchbadge&#x2F;sqlx

4 comments

PaulHouleabout 2 years ago
What about <a href="https:&#x2F;&#x2F;docs.datomic.com&#x2F;on-prem&#x2F;query&#x2F;query.html" rel="nofollow">https:&#x2F;&#x2F;docs.datomic.com&#x2F;on-prem&#x2F;query&#x2F;query.html</a><p>and more generally<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Datalog" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Datalog</a> ?<p>(Around 2010 I was frustrated with the state of OWL&#x2F;RDF&#x2F;SPARQL and all that and was curious about Datalog and found it was truly obscure and hard to find good reading about, interest in Datalog has exploded since then.)<p>Note SQL has subqueries and in some sense is &quot;composable&quot;, there are even some advanced features like<p><a href="https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;queries-with.html" rel="nofollow">https:&#x2F;&#x2F;www.postgresql.org&#x2F;docs&#x2F;current&#x2F;queries-with.html</a><p>it is ugly as hell and has problems with consistently using unique names (like the &quot;hygenic macro&quot; problem) but you can write crazy-complicated queries in SQL.
surprisetalkabout 2 years ago
You might be interested in Q, which is the query language for kdb:<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Q_(programming_language_from_Kx_Systems)" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Q_(programming_language_from_K...</a>
eimrineabout 2 years ago
It may be great to have a functional language which will write you an SQL query, but I have a hard time to image how else are you going to use a language for describing immutable data structures to edit mutable things.<p>Maybe you will be interested in Erlang as a functional way to manage something as mutable as network stream.<p>Maybe you need to learn about array programming languages (APL, J, K). They say about SQL as &quot;to suck data throw a thin pipe&quot; after APL experience.<p>Maybe you will like dealing with pure AST (I&#x27;m talking about Lisp) with no databases at all.
nhgiangabout 2 years ago
Based on your comment about composability, I&#x27;m assuming that&#x27;s what you actually meant by &quot;functional&quot;? Perhaps you want maps &amp; folds over queries?
评论 #35628030 未加载