-
Notifications
You must be signed in to change notification settings - Fork 8
add model based nominal type system #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
f7def26
to
60b858c
Compare
f20b15b
to
cd2fe03
Compare
cd2fe03
to
7382637
Compare
}, | ||
}); | ||
export class Todo extends Model.Class<Todo>('Todo')({ | ||
id: Model.Generated(Types.Text), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this will be moved to be implicit and doesn't have to be defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely like the use of Model
. The approach feels really clean.
It does create a bit of a change that in order to define a "schema", we end up defining multiple models, vs the single schema object we did have. Which feels more like a database approach to solving it, vs a document approach.
All-in-all, I think I prefer this approach.
@fubhy curious on the use of Model
from @effect/sql
vs the Data
or Schema
class from effect
??
We'd be using |
We need encoding & decoding capabiltiies (encode to write to store in a serialized, json-safe format and, when selecting from the store ( Therefore, we must use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks amazing! Just added a few questions.
|
||
it('should update an entity', () => { | ||
const { result: createResult } = renderHook(() => useCreateEntity(), { | ||
const { result: createResult } = renderHook(() => useCreateEntity(Person), { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this model, can an entity still have many types? Is this making it so we only create an entity of type person? Or could we define it so that when you create the entity it has types: Person, Artist, Historical figure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For such a case, we'd probably require the explicit creation of a polymorphic entity, e.g. something along these lines:
useCreateEntity(Model.Polymorphic(Person, Artist, Historical))
That said, this is actually impossible to represent with "mathematical accuracy / determinism" as soon as there's overlapping field declarations with different schema constraints. As such, with a polymorphic type you are essentially throwing away constrained domain modeling. I'm also not sure if I'm seeing the use-case. But I've not been in those discussions.
833d6d9
to
f06c94c
Compare
No description provided.