AlgebraicJulia / GATlab.jl

GATlab: a computer algebra system based on generalized algebraic theories (GATs)
https://algebraicjulia.github.io/GATlab.jl/
MIT License
23 stars 2 forks source link

`Ob` should construct an `Ob`, not verify #86

Closed olynch closed 11 months ago

olynch commented 11 months ago

Currently we overload the type constructors for a GAT to check the validity of their arguments. Instead, we should have something like

checkvalidity(::typeof(Ob), x)

and then

Ob(x) = checkvalidity(Ob, x) ? x : throw(ValidationError(x))

We could also have checkvalidity return the reason why x is not valid, for better error messages.

H/t @jpfairbanks for noticing that the way we were using the GAT type constructors was not Julia-idiomatic.