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

Remove the Model abstract type, simplify model migration code. #172

Open
wants to merge 2 commits into
base: withmodel_subtype
Choose a base branch
from

Conversation

kris-brown
Copy link
Collaborator

This PR removes the Model abstract type which was overly constraining (preventing one and the same struct from being a model of many different theories). One purpose the Model type served was to make it easy to see what Julia types were associated with the theory type constructors, but this functionality is now provided by impl_type methods which get defined by @instance.

This also led to an opportunity to simply model migration code, which is no longer handled convolutedly within the module of a @theorymap but instead is a function (which calls eval to create a new struct which just wraps the input model). If we start actually using model migrations and get worried about generating too many structs, it wouldn't be hard to cache the inputs to this function.

All interesting changes are in ModelInterface.jl. Lots of tiny changes (mostly removing <: Model{...} are in other files.

typecon too

allow subtyping in WithModel

Change how import works.

remove redundant Using Gatlab

.

.

fix docstrings

.
Copy link

codecov bot commented Dec 8, 2024

Codecov Report

Attention: Patch coverage is 93.65079% with 4 lines in your changes missing coverage. Please review.

Project coverage is 95.43%. Comparing base (be9b7d5) to head (86e6d51).

Files with missing lines Patch % Lines
src/models/ModelInterface.jl 93.18% 3 Missing ⚠️
src/syntax/gats/gat.jl 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           withmodel_subtype     #172      +/-   ##
=====================================================
- Coverage              95.56%   95.43%   -0.14%     
=====================================================
  Files                     38       38              
  Lines                   2234     2257      +23     
=====================================================
+ Hits                    2135     2154      +19     
- Misses                    99      103       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@kris-brown kris-brown linked an issue Dec 8, 2024 that may be closed by this pull request
@kris-brown kris-brown self-assigned this Dec 9, 2024
@kris-brown kris-brown changed the title Remove the Model abstract type, simply model migration code. Remove the Model abstract type, simplify model migration code. Dec 9, 2024
@kris-brown kris-brown added the enhancement New feature or request label Dec 9, 2024
@kris-brown kris-brown changed the base branch from main to withmodel_subtype December 9, 2024 21:51
@@ -75,20 +71,26 @@ struct ImplementationNotes
end

"""
`implements(m::Model, tag::ScopeTag) -> Union{ImplementationNotes, Nothing}`
`implements(m::MyModel, tag::ScopeTag) -> Union{ImplementationNotes, Nothing}`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be on the first line indented by 4 spaces to make it monospace?


using MLStyle
using DataStructures: DefaultDict, OrderedDict

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this is just moved from above.


implements(m::Model, theory_module::Module) =
impl_type(m, mod::Module, name::Symbol) =
impl_type(m, gettag(ident(mod.Meta.theory; name)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remind me what the ;name without a kwarg does?

@@ -9,13 +9,15 @@ using StructEquality
hom::HomT
end

@struct_hash_equal struct SliceC{ObT, HomT, C<:Model{Tuple{ObT, HomT}}} <: Model{Tuple{SliceOb{ObT, HomT}, HomT}}
@struct_hash_equal struct SliceC{ObT, HomT, C}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this massive reduction in type constraining code

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

Successfully merging this pull request may close these issues.

Using the same struct as a model for multiple theories
2 participants