feature: add flag, typing to DblTheory to match RFC-0001#1145
Open
tslil-topos wants to merge 1 commit intomainfrom
Open
feature: add flag, typing to DblTheory to match RFC-0001#1145tslil-topos wants to merge 1 commit intomainfrom
tslil-topos wants to merge 1 commit intomainfrom
Conversation
The particular interpretation of that RFC here is as follows: * constraint: change no code outside of the theory definitions * constraint: allow users of the DblTheory trait to depend on the type system to know whether hom_types are always present * implementation trick: "shallow" dependant typing, `fn hom_type(&self, x: Self::ObType) -> <Self::Kind as DblTheoryKind>::Wrap<Self::MorType>;` * when DlTheoryKind is Categorical, Wrap = Id, when it's SetTheoretic, Wrap = Option Notes: * there was a blanket implementation of DblTheory from VDCWithComposites. This has been macro-ised as `imlp_dbl_theory`, relaxed from blanket to allow more flexible use * the error messages in hom_op were slightly more informative, distinguishing self.unit_ext(y) from self.through_unit(cell, 0) failures, now these failures are not distiguished Several other design approaches were weighed and dismissed: * BaseDlbTheory with sub traits DblTheory and SetTheoreticDblTheory: introduces more code, more concepts to juggle, lots of duplication * hom_type returns Option always, with flag on impl: no type system guarantees, adds .unwrap() boilerplate to call sites, forces us to specialise the blanket implementation anyway * DblTheory<Categorical> and DblTheory<SetTheoretic> as separate traits: loss of ergonomics at call sites, would be two copies of every method, Rust doesn't pick for you * UnitalDblTheory supertrait with user contracts: still not strong enough guarantee, have to update call sites
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The particular interpretation of that RFC here is as follows:
fn hom_type(&self, x: Self::ObType) -> <Self::Kind as DblTheoryKind>::Wrap<Self::MorType>;DblTheoryKindisCategorical, Wrap = Id, when it'sSetTheoretic, Wrap = OptionNotes:
imlp_dbl_theory, relaxed from blanket to allow more flexible useSeveral other design approaches were weighed and dismissed:
DblTheory<Categorical>andDblTheory<SetTheoretic>as separate traits: loss of ergonomics at call sites, would be two copies of every method, Rust doesn't pick for youCloses #1099