Extending an existing record

Have you thought about using Result.map4 or Result.Extra.andMap instead? The basic idea is that you can construct a partial result by partially applying the constructor, so Result.map ProjectFile getSubSystems would conditionally give you a partial ProjectFile, where you either filled in the subsystems, or you got an Err instead.

From a very quick look at the links you posted, I can’t find a place where you needed to cross-refernce something (getEntities doesn’t need to know about .subsystems), which would complicate things are little bit.

If you want to collect all the errors instead of just returning the first one, it might also be an idea to use a different Result a type, like the one from the-sett/elm-error-handling.

2 Likes