Skip to content

Conversation

@FlandiaYingman
Copy link

@FlandiaYingman FlandiaYingman commented Dec 14, 2025

A very naive implementation of contextual parameters via flow analysis!

There are still a lot of difficulties to research on... 😬

Copilot AI review requested due to automatic review settings December 14, 2025 16:46
@FlandiaYingman FlandiaYingman marked this pull request as draft December 14, 2025 16:46

This comment was marked as outdated.

@FlandiaYingman
Copy link
Author

TODOs

  • Basic Implicit Parameters

    This is nothing special than the contextual resolution in the (basic) resolution stage. I'll just have to store the "implicit context" for each resolvable term, and then query the corresponding instances if the flow-analyzed term (sel or app) really points to a function (or method) that accepts a list of implicit parameters.

    fun f(using x: Int) = x
    using Int = 42
    f // = 42
  • Type Classes

    I'll add Consumer.TypeClassInstance as suggested in the last meeting to flow-analyze the type of the instance to be queried. This supports the usage of implicit parameters such as

    fun f(using Monoid[T]) = ...
    using Monoid[Int] = ...
    f
    // solve ?T <: TypeClassInstance(Monoid, ?ev1) for some ?ev1: Monoid[?A]
  • Curried Implicit Parameter Lists

    I'll have to deal with the cases that a function can have multiple interleaving parameter lists, either regular or implicit. This shouldn't be too hard but requires some mechanical functions (which were already implemented in the basic resolver, I just have to adapt it to the flow resolver) to zip the parameter lists and the argument lists.

    fun f(using Int)()(using Int) = ...
    using Int = 42
    f()

//│ = 43


:todo
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, it looks like we do not deduplicate identical selection targets?

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

Successfully merging this pull request may close these issues.

2 participants