Open raymens opened 9 years ago
And an additional method to support chaining multiple RopResults and rearranging (or discarding) them. Don't mind the excessive type arguments ;)
let combine2R (comb : 'a * 'c -> 'd) (func : 'a -> RopResult<'TResult, 'TDomainMessages>) =
let concat (functie : 'a -> RopResult<'TResult, 'TDomainMessages>) (arg : 'a) =
match functie arg with
| Success (result, msgs) -> Success((comb (arg, result)), msgs)
| Failure(x) -> Failure(x)
bindR (concat func)
Used like:
|> combineR (fun ((x), d) -> (x, d)) getUserAndCheckRules
This is meant as a suggestion and question at the same time, I'm very interested about your thoughts on using ROP and DDD for this.
One of my DAL functions is dependent on multiple tables which I have seperated into multiple DALs. Instead of copying these functions etc., I wanted them to accept an entity in the DAL function.
Like:
GroupDao.Create(groupDomainModel, user)
Where the groupDomainModel is converted from a DTO supplied by input. And the user is derived from login info. So this user has to be derived prior to calling the GroupRepository.
So I created the function combineR listed below for this 'problem'.
This can then be used like this:
Do you have any opinion about this?
(example is not code I'm using, but the best example I could think of)