Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialize concrete acset schemas #63

Open
filonik-cmu opened this issue Oct 2, 2023 · 2 comments
Open

Serialize concrete acset schemas #63

filonik-cmu opened this issue Oct 2, 2023 · 2 comments
Assignees

Comments

@filonik-cmu
Copy link

filonik-cmu commented Oct 2, 2023

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:

@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:

@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:

{
  "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: #45

@KevinDCarlson
Copy link

Copying this from #45 :

New comments from Daniel today:

The real problem is that we have our schema in Catlab and it's generic over the actual types populating the AttrTypes to create a concrete acset type. Thus we'd like to serialize a schema with fixed AttrTypes, probably both on its own and along with the serialization of an instance. We mainly just need primitive types.

@KevinDCarlson KevinDCarlson self-assigned this Oct 16, 2023
@jpfairbanks
Copy link
Member

This is definitely being worked on via InterTypes #76

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants