edumentab / cqrs-starter-kit

A starter kit for working with CQRS and intentful testing.
http://cqrs.nu/
BSD 3-Clause "New" or "Revised" License
457 stars 137 forks source link

F# example? #8

Open ImaginaryDevelopment opened 8 years ago

ImaginaryDevelopment commented 8 years ago

any chance you'd be interested in doing this in F# also? It seems there's a lot of code that on the surface (I have zero experience, but guessing) that a lot of the code is completely unnecessary with F#.

For example based on my understanding of Cqrs as it would be used in F#, you could define the aggregate type as follows:

type Aggregate<'t> = {Id:Guid;EventsLoaded:int; Data:'t;}
    with member x.ApplyEvent(fEvent) : Aggregate<'t> * _ list = fEvent x |> (fun (a,events) -> {a with EventsLoaded = Seq.length events + a.EventsLoaded},events)

pardon my intrusion if you aren't into F#, but if you are, I'd love feedback on my interpretation and attempt at application of your example into my preferred language.

jchannon commented 4 years ago

@ImaginaryDevelopment bit late but I'd like to see that