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

Refactor FinitaryCategory Type Class #25

Open
3 of 5 tasks
Tracked by #50
jsbezerra opened this issue May 8, 2017 · 9 comments
Open
3 of 5 tasks
Tracked by #50

Refactor FinitaryCategory Type Class #25

jsbezerra opened this issue May 8, 2017 · 9 comments

Comments

@jsbezerra
Copy link
Member

jsbezerra commented May 8, 2017

Refactor the Morphism type class, renaming it to FinitaryCategory to better match its responsabilities.

At the same time, implement @ggazzi's suggestion of using a Context Monad to store important information about the category, such as the type graph of a TGraph and the type graph and NAC strategy of a TSpan.

  • Rename Morphism to FinitaryCategory
  • Add a "context monad" to the type classes
  • Flip the arguments of compose and add an alias (<&>)
    • To do the same thing for Data.Relation ?
  • Integrate FindMorphism into FinitaryCategory
@jsbezerra
Copy link
Member Author

This will cause a major API change, so we need to discuss this better.

@jsbezerra
Copy link
Member Author

jsbezerra commented May 8, 2017

Question: should we also change the order of paramaters in the compose function to reflect exactly the category operator?

@ggazzi
Copy link
Member

ggazzi commented May 8, 2017

In this case it might even make sense to use some sort of operator for morphism composition. Clearly we can't use (.) which is already function composition.

One possibility would be to define an instance of the Semigroup class, so we could use the (<>) operator. I don't think this would fit, though, since some morphisms aren't actually composable so it might violate the laws of the Semigroup class.

Otherwise, we need to find an operator that is not too noisy and doesn't clash with common Haskell libraries.

@jsbezerra
Copy link
Member Author

It makes sense. We could use <&>

https://www.haskell.org/hoogle/?hoogle=%3C%26%3E

@ggazzi
Copy link
Member

ggazzi commented May 8, 2017

The name FinitaryCategory would be technically more appropriate than FiniteCategory. A finitary category where each object is finite (i.e. has a finite number of subobjects), but the number of objects may be infinite.

@ggazzi ggazzi added this to Architecture Review in verigraph May 8, 2017
@jsbezerra
Copy link
Member Author

Updated

@ggazzi ggazzi changed the title Refact Morphism Type Class Refactor Morphism Type Class May 9, 2017
@ggazzi
Copy link
Member

ggazzi commented May 9, 2017

@lm-rodrigues once suggested to me that FindMorphism might be unnecessary, since all instances of Morphism should also implement FindMorphism. I think this is even more true of FinitaryCategory: since the objects are finite, finding morphisms between them is definitely decidable.

How about we integrate FindMorphism into FinitaryCategory?

@jsbezerra jsbezerra changed the title Refactor Morphism Type Class Refactor FinitaryCategory Type Class May 19, 2017
@jsbezerra jsbezerra mentioned this issue May 22, 2017
7 tasks
@jsbezerra
Copy link
Member Author

About the integration of FindMorphism and FinitaryCategory:

What would be the case for the Category Graph, which today only implements FinitaryCategory?

Should we also implement FindMorphism for it (even though we do not use it) or should we leave it unimplemented and raise and error accordingly?

@ggazzi
Copy link
Member

ggazzi commented May 22, 2017

Good point. As it stands, I think it would be best to keep these type classes separate, since they do express separate concerns (the "definition" of a finitary category is independent of the algorithms for finding morphisms between its objects).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
verigraph
Architecture Review
Development

No branches or pull requests

3 participants