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

Revisit contextual function type ordering for UDFs #153

Open
jspenger opened this issue May 11, 2023 · 0 comments
Open

Revisit contextual function type ordering for UDFs #153

jspenger opened this issue May 11, 2023 · 0 comments
Labels
area:core Portals core discuss Discussion encouraged itype:meta Meta discussion stat:backlog No work planned for time being

Comments

@jspenger
Copy link
Member

One of the pervasive issues in Portals has to do with context functions. For example, this is the current implementation of the MapTask in Portals:

private[portals] case class MapTask[T, U](f: TaskContextImpl[T, U, _, _] => T => U)
    extends BaseTask[T, U, Nothing, Nothing]:
  override def onNext(using ctx: TaskContextImpl[T, U, Nothing, Nothing])(t: T): Unit = ctx.emit(f(ctx)(t))
end MapTask // trait

However, this is the corresponding method from the factory/builder:

def map[T, U](f: MapTaskContext[T, U] ?=> T => U): GenericTask[T, U, Nothing, Nothing] =
    MapTask[T, U](ctx => f(using ctx))

Another thing is awkward is passing a contextual function f as an argument to anything: it will always cause an error that it cannot find a contextual value, and instead one has to write something like c ?=> f(using c) regardless.

The awkwardness stems from that a case class cannot have as a parameter a contextual function type. So, at an earlier point in the implementation, the choice was made to do it as above. Now, it is perhaps a good time to revisit this principle, as after some more recent trials other potential work-arounds have surfaced.

One option could be to have the contextual parameter not as the first parameter, like the following:

private[portals] case class MapTask[T, U](f: T => TaskContextImpl[T, U, _, _] ?=>  U) ...

The second option could be to have it as a second parameter list, like the following:

private[portals] case class MapTask[T, U]()(f: TaskContextImpl[T, U, _, _] ?=> T => U) ...

// Rant over

We should revisit this at some point.

@jspenger jspenger added discuss Discussion encouraged area:core Portals core itype:meta Meta discussion labels May 11, 2023
@jspenger jspenger added the stat:backlog No work planned for time being label Aug 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core Portals core discuss Discussion encouraged itype:meta Meta discussion stat:backlog No work planned for time being
Projects
None yet
Development

No branches or pull requests

1 participant