Skip to content
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

Sugar for models with union types #164

Closed
kris-brown opened this issue Oct 15, 2024 · 2 comments
Closed

Sugar for models with union types #164

kris-brown opened this issue Oct 15, 2024 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@kris-brown
Copy link
Collaborator

kris-brown commented Oct 15, 2024

If Ob is implemented by Union{A,B} for some model, then when declaring the model one is forced to write something like

@instance ThCategory{Union{A,B}, ...} [model::MyModel] begin

  id(x::Union{A,B}) = x isa A ? (... some A logic ...) : (... some B logic ...)

  ...
end

A multiple dispatch style approach would be preferred:

id(x::A) = ...
id(x::B) = ...
@kris-brown kris-brown added the enhancement New feature or request label Oct 15, 2024
@kris-brown kris-brown self-assigned this Oct 15, 2024
@kris-brown
Copy link
Collaborator Author

kris-brown commented Oct 15, 2024

The problem is worse for if Hom were implemented by a union type, since compose would have four possibilities. Hopefully it is not too much of a hassle to handle all the possible cases (including explicit Union types).

@kris-brown
Copy link
Collaborator Author

Another problem is that there is a difference between implementing both A and B and implementing Union{A,B}, even for a unary operation. So this idea doesn't really work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant