AlgebraicJulia / AlgebraicJulia/ACSets.jl

Serialize concrete acset schemas

Đang mở
#63 2 bình luận 0 reaction 1 người được giao Được @KevinDCarlson nhận Xem trên GitHub
Ngôn ngữ chính
Julia
Star
36
Fork
11
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.