Rescript in neovim
@dkirchhof thanks for sharing your configuration. It’s still not working for me. So there is definitely something off. I’ll have to upgrade my neovim and lazyvim to latest, but that’s a breaking...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
also, is there a difference between these two: module Log = unpack(deps.getLog("foo")) let module(Log) = deps.getLog("foo") do i prefer one or the other. or do they have different uses?
View ArticleModule functors vs. records-of-functions for interface/implementation separation
I think I’d stick to module functions for such use cases, I’m not sure first-class modules and function records bring any benefit here. In general try to use the least powerful tool for the job. It’s...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
maybe i’m not being clear. there are two main concepts i’m discussing here: interfaces (think ports and adapters) and a composition root (think dependency injection) i understand your point on...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
I tried the hexagonal / ports and adapters architecture in a rescript app as well. I had the same questions in mind. Should I pass single functions, records of functions or modules. Since I didn’t...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
thanks. I’m experimenting a bit. we do records-of-fns now, or capability records, because it’s ergonomic. but it always bothered me to have type t for behaviors (in essence, modules, or in hex-ddd...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
I think it’s not a by chance that there’s no convention and few articles about that in rescript/ocaml or functional languages in general. A big motivation of dependency injection comes from the...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
if you really need to pass around some dependencies, I’d likely use something like that: module DepsTypes = { module type Console = { let log: string => unit } module type T = { module Console:...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
thanks, interesting input. I agree with you in general terms, but in real-world scenarios, especially for larger production systems, the “edges” are everywhere, you have side-effects all over the...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
experimenting with this, i threw this contrived but i think relevant example together: // src/Deps.res module Clock = SystemClock module BaseLog = TimestampedLog.Make(Clock, ConsoleLog,...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
So at CCA we are mostly using implementation records for dependency injection. Don’t know if it’s idiomatic ReScript, but it does not need any concepts that JS devs are unfamiliar with. Here is a...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
Sure the real world is impure, but it doesn’t mean your whole code has to be! The Clean Architecture that reuses most of the principles of the hexagonal architecture recommends to keep your...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
it’s what i’ve been doing too. you’re using a static impl though which is sort of a no-no to me but it makes sense just from the name (you likely won’t be running your app instance on more than one...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
absolutely agree with this take, but my reasoning focuses on the particular areas where there is interaction (hence Clock and Log above in the examples). i’m actually leaning towards module functions...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
At least somewhat related, but you can also use ReScript objects if you want to leverage full inference for DI. Here’s an example that uses %typeof, which does not exist yet (but there’s a PoC of): //...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
your last example here is actually incredibly cool of its inner workings, although using strings feels kinda meh, but on the other hand as i’m exploring module functions for DI, that syntax is...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
Strings for the property access?
View ArticleModule functors vs. records-of-functions for interface/implementation separation
yeah, exactly, it it doesn’t look too nice but turns out module functions don’t either (tbh it seems like the Module Function syntax has sort of been forgotten about with regard to how fresh the rest...
View ArticleModule functors vs. records-of-functions for interface/implementation separation
What would be better for access? A variant?
View ArticleModule functors vs. records-of-functions for interface/implementation separation
i had dot-syntax i mind like ctx.log
View Article