AlgebraicJulia / AlgebraicJulia/ACSets.jl

Serialize concrete acset schemas

未關閉
#63 2 則留言 0 個 reaction 已指派 1 人 已被 @KevinDCarlson 認領 在 GitHub 檢視
主要語言
Julia
星號
36
分支
11
PR 合併指標
30 天內沒有已合併 PR

描述

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

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。