These are chat archives for YoEight/eventstore

3rd
Jan 2017
Akii
@Akii
Jan 03 2017 19:26
@YoEight I'm there :D
Akii
@Akii
Jan 03 2017 19:34
wow almost a year since I was last here
Yorick Laupa
@YoEight
Jan 03 2017 19:38
I'm here @Akii
Time flies by :smile:
Akii
@Akii
Jan 03 2017 19:39
hey :D
ye
but I was not lazy
just slow
so eventstores
they're strange beasts
would you agree that you can bring down getEventStore to a simplified type of type EventStore = [(EventType, Value)]?
Yorick Laupa
@YoEight
Jan 03 2017 19:40
I try to formalize some part of those
Akii
@Akii
Jan 03 2017 19:40
no wait
that'd be a stream
Yorick Laupa
@YoEight
Jan 03 2017 19:40
no prob
Akii
@Akii
Jan 03 2017 19:41
also store but the store would have a list of streams
anyway :D
this is so dynamic
Yorick Laupa
@YoEight
Jan 03 2017 19:41
to be more precise, it should've been [(Int, EventType, Value)]
Akii
@Akii
Jan 03 2017 19:41
Int being the version?
Yorick Laupa
@YoEight
Jan 03 2017 19:42
the position within the stream
Akii
@Akii
Jan 03 2017 19:42
yes :D
Yorick Laupa
@YoEight
Jan 03 2017 19:42
it's useful in certain usecases
Akii
@Akii
Jan 03 2017 19:42
I just assumed an ordered list
Yorick Laupa
@YoEight
Jan 03 2017 19:42
alright
Akii
@Akii
Jan 03 2017 19:42
now in getEventStore you can combine those like crazy
Yorick Laupa
@YoEight
Jan 03 2017 19:42
we keep it simple then [(EventType, Value)]
Akii
@Akii
Jan 03 2017 19:43
now what I'm currently doing is building a protocol
this is like the far other side of the app now
so I say there is this context that emits events
and you end up with data MyEvent = A | B | C
so the initial need is to get an event type out of that
lets form a set for those {"A", "B", "C"}
great
Yorick Laupa
@YoEight
Jan 03 2017 19:45
ok
Akii
@Akii
Jan 03 2017 19:45
now what I did is basically a way to query the store for a given Haskell type
by defining this set
for each type
Yorick Laupa
@YoEight
Jan 03 2017 19:47
I got that
Akii
@Akii
Jan 03 2017 19:47
nice first step but this is not doing so great when streams don't align to those data types
more context needed I think
lets say I have a bounded context that emits a sum type
Yorick Laupa
@YoEight
Jan 03 2017 19:48
by align, you mean a stream with a type you haven't defined ?
Akii
@Akii
Jan 03 2017 19:48
more like a stream that consists of more than one Haskell type
Yorick Laupa
@YoEight
Jan 03 2017 19:48
or a type not associated with the right value
ok
Akii
@Akii
Jan 03 2017 19:48
imagine two contexts having their sum type of events
and then you start composing streams on a db level
(which is really easy to do)
like you form the "context A and B stream"
and suddenly you need to form a sum type on type level
Yorick Laupa
@YoEight
Jan 03 2017 19:49
that's where I don't follow you
Akii
@Akii
Jan 03 2017 19:49
this is what I meant with that my code doesn't align with streams
:D ha
Yorick Laupa
@YoEight
Jan 03 2017 19:50
I challenge the part where you saying you need to form a sum type on type level
for me it isn't necessary
Akii
@Akii
Jan 03 2017 19:52
lets quickly make sure we're both on the same track
bounded context is like this system working on its own emitting events
and you have several of those
Akii @Akii waves hands
Akii
@Akii
Jan 03 2017 19:54
let me quickly come up with a meaningful example
Yorick Laupa
@YoEight
Jan 03 2017 19:54
would you like to be able to query events related to 2 differents only that's right ?
yes it could help
an example showcasing a call at site usage would be great
lets go with that
lets also say you don't do event sourcing and just stick those into two streams
product-catalog stream and the basket stream
the sum of all events in the store will be a sum type of those types
gotta be
so loadAllTheThings :: [Either ProductEvent BasketEvent]
the ideal data type for an event store would of course include all the event types
Akii
@Akii
Jan 03 2017 20:04
but that isn't quite what I'd expect
or want
which is why I went and just declared a bounded enum type for each event sum type
so I could go there and say "I want X and X has this set of event types and I will just ignore everything else you throw at me"
does not align with stream types per se but I could make a new type for that
unfortunately this is not how getEventStore works
because you just don't go there asking for event types
(I've created a semi-event store in the past where I could just query for types; there were no notion of streams)
Akii
@Akii
Jan 03 2017 20:10
okay so maybe I'm lacking a piece of knowledge
how would you retrieve a stream of events
Yorick Laupa
@YoEight
Jan 03 2017 20:12
I continue to say all you need there is Typeable
Besides
Akii
@Akii
Jan 03 2017 20:12
I'm probably looking at this tomorrow and will be facepalming so hard
Yorick Laupa
@YoEight
Jan 03 2017 20:13
in your case it doesn't look like you really need EventType neither
because at the end
you asking for those event data types
namely ProductEvent and BasketEvent
with no mention of EventType whatsoever
Akii
@Akii
Jan 03 2017 20:15
well the EventType directly translates into one of the other
the eventstore gives you type + value
literally
Yorick Laupa
@YoEight
Jan 03 2017 20:15
Typeable can give you the same feature
to be precise, eventstore gives you a type an a raw bytestring
Akii
@Akii
Jan 03 2017 20:16
I give eventstore a type
and it gives me back that type :D
Yorick Laupa
@YoEight
Jan 03 2017 20:16
It up to you deserialize it to the type you want
Typeable my friend
hold on
Akii
@Akii
Jan 03 2017 20:16
yes, I think that'll be the solution xD
Yorick Laupa
@YoEight
Jan 03 2017 20:19
look at gcast2
nevermind
data SomeEvent = forall e. Typeable e => SomeEvent e
And you that structure to store your event in your stream
you can easily implement a function that does the following
retrieve :: (Typeable a, Typeable b) => Stream -> [Either a b]
with the help of cast function
Akii
@Akii
Jan 03 2017 20:23
that sounds like complete magic atm :D
Yorick Laupa
@YoEight
Jan 03 2017 20:24
does it looks like a function that does what you need ?
Akii
@Akii
Jan 03 2017 20:24
this looks like generic programming one can understand
that's definitely not the function I need though
but this is a great starting point
I'll look into this more tomorrow
Yorick Laupa
@YoEight
Jan 03 2017 20:27
It might need some details here and there
but I think it might be the core of your idea
Akii
@Akii
Jan 03 2017 20:28
yes I think so too
thank you for your time! :D
Yorick Laupa
@YoEight
Jan 03 2017 20:28
sure
Akii
@Akii
Jan 03 2017 20:28
I'll make sure to put that to good use
Yorick Laupa
@YoEight
Jan 03 2017 20:29
thx
:smile:
Akii
@Akii
Jan 03 2017 20:29
I'll ofc also report any bug I'll find
^^
and help in any way I can
my whole architecture kinda relies on the fact that I get an event subscription
additionally I think that this library you wrote really helps getting Haskell adopted in "the real world"
or at least in "the real world" from where I come xD
Akii
@Akii
Jan 03 2017 20:34
which is domain-driven design
so yeah, cool :)
Yorick Laupa
@YoEight
Jan 03 2017 21:06
@Akii Thanks, I gonna continue on that front