AlgebraicJulia / AlgebraicJulia/ACSets.jl

Serialize concrete acset schemas

オープン
#63 コメント 2 件 リアクション 0 件 担当者 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 を短くまとめたダイジェスト。