# Functor Syntax is not working

**URL:** <https://discourse.julialang.org/t/functor-syntax-is-not-working/97631>\
**Category:** General Usage\
**Tags:** question\
**Created:** [April 18, 2023, 8:38pm UTC](https://discourse.julialang.org/t/functor-syntax-is-not-working/97631 "2023-04-18T20:38:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nobel\_Chowdary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nobel_chowdary/32/45850_2.png) [@Nobel\_Chowdary](https://discourse.julialang.org/u/Nobel_Chowdary)\
**Post date:** [April 18, 2023, 8:38pm UTC](https://discourse.julialang.org/t/functor-syntax-is-not-working/97631/1 "2023-04-18T20:38:11Z")

</div>

The following code shows the two schemas and a functor between them. However, the basic syntax of the functor is throwing errors. Can someone help me with this?

```julia
using Catlab, Catlab.Theories, Catlab.CategoricalAlgebra
@present Sch1(FreeSchema) begin
  (N1, N2)::Ob
  f::Hom(N1,N2)

  (Name, Salary, Age)::AttrType
  name::Attr(N1, Name)
  salary::Attr(N1, Salary)
  age::Attr(N2, Age)
end

@present Sch2(FreeSchema) begin
  N::Ob
  (Name, Salary, Age)::AttrType
  name::Attr(N, Name)
  salary::Attr(N, Salary)
  age::Attr(N, Age)
end

using Test

using Catlab, Catlab.Graphs, Catlab.CategoricalAlgebra
using Catlab.Programs.DiagrammaticPrograms
using Catlab.Programs.DiagrammaticPrograms: NamedGraph
using Catlab.WiringDiagrams.CPortGraphs

F = @finfunctor Sch1 Sch2 begin
    N1 => N;
    N2 => N
end

```

Error

- Output exceeds the size limit. Open the full output data in a text editor

Object N1 is not assigned Stacktrace: [1] error(s::String)\*

 ![image](https://global.discourse-cdn.com/julialang/original/3X/c/4/c4662cdcf09a39bc2d9c9c5336f97f74f93807fa.png)

---

<div class="post-metadata">

**Author:** ![adienes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/adienes/32/37459_2.png) [@adienes](https://discourse.julialang.org/u/adienes)\
**Post date:** [April 18, 2023, 8:44pm UTC](https://discourse.julialang.org/t/functor-syntax-is-not-working/97631/2 "2023-04-18T20:44:37Z")

</div>

I don’t know anything about Catlab, but as a general note it will be easier to help if you paste the code as text rather than a screenshot.

---

<div class="post-metadata">

**Author:** ![Nobel\_Chowdary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nobel_chowdary/32/45850_2.png) [@Nobel\_Chowdary](https://discourse.julialang.org/u/Nobel_Chowdary)\
**Post date:** [April 18, 2023, 8:51pm UTC](https://discourse.julialang.org/t/functor-syntax-is-not-working/97631/3 "2023-04-18T20:51:09Z")

</div>

Thanks will edit it

---

<div class="post-metadata">

**Author:** ![slwu89](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/slwu89/32/217323_2.png) [@slwu89](https://discourse.julialang.org/u/slwu89)\
**Post date:** [August 24, 2023, 4:11pm UTC](https://discourse.julialang.org/t/functor-syntax-is-not-working/97631/4 "2023-08-24T16:11:33Z")

</div>

Hope this is not too late, but here is how to use `@finfunctor` to make a functor between those two schemas (small categories) and then use it to preform a data migration on instances of data on those schemas (Sch1 to Sch2), which is what I assume you were working towards. On Catlab v0.15.3 (we can just use a single `using Catlab` to import everything now).

```julia
using Catlab

@present Sch1(FreeSchema) begin
  (N1, N2)::Ob
  f::Hom(N1,N2)

  (Name, Salary, Age)::AttrType
  name::Attr(N1, Name)
  salary::Attr(N1, Salary)
  age::Attr(N2, Age)
end

@present Sch2(FreeSchema) begin
  N::Ob
  (Name, Salary, Age)::AttrType
  name::Attr(N, Name)
  salary::Attr(N, Salary)
  age::Attr(N, Age)
end

F = @finfunctor Sch1 Sch2 begin
    N1 => N
    N2 => N
    f => id(N)
    Name => Name
    Salary => Salary
    Age => Age
    name => name
    salary => salary
    age => age
end

@acset_type Sch1Data(Sch1)
@acset_type Sch2Data(Sch2)

sch1_data = @acset Sch1Data{String,Int,Int} begin
    N1 = 3
    N2 = 3
    f = [1,2,3]
    name = ["Alice", "Bob", "Carol"]
    salary = [300, 400, 500]
    age = [25, 30, 35]
end

Σ = SigmaMigrationFunctor(F, Sch1Data{String,Int,Int}, Sch2Data{String,Int,Int})
Σ(sch1_data)

```
