You could also go:
type userId =
let getUser = (userId: userId) /* ... */
Sure, calling getUser(UserId(user.id)) is as verbose as getUser(~userId: user.id)—provided you want to leave those naked strings in all the other places. But maybe it makes more sense to have app-wide userId type anyway and not let strings wander any further than JSON encoding/decoding and suchlike.
You could probably also use phantom types, but I’m not sure if those are easy to use across modules, or whether putting all the user-related business logic in the User module is actually better than just an app-wide type. I’m still new to functional languages.
Definitely other good approaches. Thanks, Sergey!
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.