AlgebraicJulia / AlgebraicJulia/ACSets.jl
Serialize concrete acset schemas
- Langage dominant
- Julia
- Étoiles
- 36
- Forks
- 11
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
Currently, we have the ability to serialize the abstract acset schemas and concrete acset instances.
For example, we can define and serialize this abstract schema:
```julia
@present SchFriends(FreeSchema) begin
(Person,Friendship)::Ob
(friender,friendee)::Hom(Friendship,Person)
(Name, Age)::AttrType
name::Attr(Person,Name)
age::Attr(Person,Age)
end
write_json_acset_schema(SchFriends, "SchFriends.json")
```
And we can define and serialize this concrete instance:
```julia
@acset_type Friends(SchFriends, index=[:friender,:friendee])
friends = @acset Friends{String,Int} begin
Person = 3
Friendship = 3
friender = [1,2,2]
friendee = [2,1,3]
name = ["Alice", "Bob", "Carol"]
age = [20, 30, 40]
end
write_json_acset(friends, "friends.json")
```
However, even when taking both of them together, there is some type information missing. Specifically, what is currently missing is a way to serialize the concrete schema (i.e. `Friends{String,Int}`) for a given acset instance. The information is only implicitly/dynamically available in the JSON, which only works for the primitive types natively supported by JSON.
What I would like is an overload like this:
```
write_json_acset_schema(friends, "SchFriends.json")
```
Which will output the same as the abstract schema, except it will also include the concrete type substituted in the `friends` instance for each of the the `AttrTypes`, i.e. it would produce something like:
```json
{
"version": { "ACSets": "0.0.0", "ACSetSchema": "0.0.1" },
"Ob": [{ "name": "Person" }, { "name": "Friendship" }],
"Hom": [
{ "name": "friender", "codom": "Person", "dom": "Friendship" },
{ "name": "friendee", "codom": "Person", "dom": "Friendship" }
],
"AttrType": [
{ "name": "Name", "type": "String" },
{ "name": "Age", "type": "Int" }
],
"Attr": [
{ "name": "name", "codom": "Name", "dom": "Person" },
{ "name": "age", "codom": "Age", "dom": "Person" }
]
}
```
This is related to issue: https://github.com/AlgebraicJulia/ACSets.jl/issues/45
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.