zenna / Arrows.jl

14 stars 2 forks source link

@arr bugs #70

Open zenna opened 7 years ago

zenna commented 7 years ago

Looking to replace some of the code with @arr

@arr function inv_add(x::Float64, θadd::Float64)
  (z - θadd, θadd)
end

yields the following error (I imagine because you use z as a standard output ( should probably change this to out_1, out_2 if we can't infer it.

julia> Arrows.@arr function inv_add(z::Float64, θadd::Float64)
         (z - θadd, θadd)
       end
ERROR: ArgumentError: name duplicates: Arrows.Name[Arrows.Name(:z), Arrows.Name(:θadd), Arrows.Name(:z)]
Stacktrace:

Using another name yields another error

julia> Arrows.@arr function inv_add(x::Float64, θadd::Float64)
         (x - θadd, θadd)
       end
Expr
  head: Symbol tuple
  args: Array{Any}((2,))
    1: Expr
      head: Symbol call
      args: Array{Any}((3,))
        1: Symbol -
        2: Symbol x
        3: Symbol θadd
      typ: Any
    2: Symbol θadd
  typ: Any
ERROR: DomainError:
Stacktrace:
 [1] transform_expr_prim!(::Expr, ::Dict{Symbol,Arrows.SubPort}, ::Arrows.CompArrow, ::Bool) at /home/zenna/.julia/v0.6/Arrows/src/macros/arr_macro.jl:127
 [2] transform_function(::Expr) at /home/zenna/.julia/v0.6/Arrows/src/macros/arr_macro.jl:155

@jburroni

jburroni commented 7 years ago

@zenna do we want to be able to do this:

  carr, f = Arrows.@arr function f(x, y)
    if x == y
      (2x + y, 1)
    else
      (2, 3x + y)
    end
  end

? If so, we would need to create a TupleArrow + IndexingArrow

zenna commented 7 years ago

Yeah. It's not a priority yet, and also we don't need any more arrows to do it: img_20171017_235103