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

Allow checking if a model does NOT implement a given theory #175

Open
wants to merge 1 commit into
base: rem_model
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/models/ModelInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ end
If `m` implements the GATSegment referred to by `tag`, then return the
corresponding implementation notes.
"""
implements(m::Module, ::Type{Val{tag}}) where {tag} = nothing
implements(m, ::Type{Val{tag}}) where {tag} = nothing

implements(m, tag::ScopeTag) = implements(m, Val{tag})

Expand Down Expand Up @@ -610,9 +610,10 @@ end

function implements_declaration(model_type, scope, whereparams)
notes = ImplementationNotes(nothing)
m = only(methods(implements, (Any, Type{Val{1}})))
quote
if !hasmethod($(GlobalRef(ModelInterface, :implements)),
($(model_type) where {$(whereparams...)}, Type{Val{$(gettag(scope))}}))
if $m == only(methods($(GlobalRef(ModelInterface, :implements)),
($(model_type) where {$(whereparams...)}, Type{Val{$(gettag(scope))}})))
$(GlobalRef(ModelInterface, :implements))(
::$(model_type), ::Type{Val{$(gettag(scope))}}
) where {$(whereparams...)} = $notes
Expand Down
1 change: 1 addition & 0 deletions test/models/ModelInterface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ end
@test_throws ErrorException codom[FinSetC()]([1,2,3])

@test implements(FinSetC(), ThCategory)
@test !implements(FinSetC(), ThNatPlus)

# Todo: get things working where Ob and Hom are the same type (i.e. binding dict not monic)
struct TypedFinSetC
Expand Down
Loading