Roc Lang – Elm but for everywhere [video]
youtube.com
youtube.com
That said, I may just be showing my lisp bias, and tools like Squirrel in Gleam are sufficient https://hexdocs.pm/squirrel/
What part of that example is bad, and the lack of macros means it stays bad? I can come up with some possibilities (e.g. response mapping), but I have no idea if they're valid or not because I don't know if that's just due to being an intentionally explicit example.
That said, it does have the fundamental issue of the query is just a string and the code author has to fundamentally deal with correctly specifying what the return type is. Technically a fancier query builder could be defined that removes the sql and instead defines both the query and return type at once to avoid the double specification.
Otherwise, something like squirrel would 100% be doable in roc. [Something similar](https://github.com/isaacvando/rtl) already exists for templating in roc via code gen.
You’d be surprised at how nice you can make a DSL in Roc without any metaprogramming!
As for Squirrel, I think it’s a great approach and definitely something I might explore in the future. Right now, I'm leaning towards a DSL for better reusability, though I must admit, that actual SQL is hard to beat!
[1] https://github.com/agu-z/roc-pg/blob/62725fe3a1d92144a8408ae...
So excited to see it continue to thrive and grow.
And I'd argue the borrow checker reduces the cognitive overhead.
There do of course exist many important use cases where a better c++ is actually what you want, and the complexity tax of that is worth paying.
There is a talk somewhere where Richard "demos" this.
main =
x = pf.NewRef!
pf.Write! x 5
y = pf.Read! x import Data.IORef
main :: IO ()
main = do
x <- newIORef (0 :: Int)
writeIORef x 5
y <- readIORef x
print y