Class/Object

polynote.runtime.macros

ExpandedScopeMacros

Related Docs: object ExpandedScopeMacros | package macros

Permalink

class ExpandedScopeMacros extends AnyRef

This macro allows for injecting orphan instances into implicit scope, as follows.

Given a typeclass org.foo.TC[A], and a separate module that wants to put instances of TC into TC's implicit scope, place a low-priority implicit fundep materialization pointing to the macro method ExpandedScopeMacros#resolveFromScope.

Then, in the separate module, create a subclass of TC, e.g. com.bar.TC1[A]. It must have the same type parameters as TC and directly extend TC with those type parameters. Place the would-be orphan instances/derivations into TC1's companion object, making them instances of TC1 rather than TC.

Then, create a resource file in the separate module called META-INF/expanded-scopes/org.foo.TC (the fully qualified class name of the original typeclass). In this file, there should be a line with the fully qualified name of each such subclass of TC, i.e. com.bar.TC1.

When instances are searched for org.foo.TC[X], and no instances with higher priority are found, the fundep macro will scan the classpath and find all such resource files, and for each subclass found it will attempt to resolve an implicit for e.g. com.bar.TC1[X] and if successful will return that as an instance of org.foo.TC[X].

This allows modules to be created containing orphan instances of TC, while still placing them in implicit scope. This is used, for example, to allow the polynote-spark-runtime module to define instances of polynote.runtime.ReprsOf that are in implicit scope for ReprsOf, without making polynote-runtime depend on spark.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ExpandedScopeMacros
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new ExpandedScopeMacros(c: Context)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. val c: Context

    Permalink
  6. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  14. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. def resolveFromScope: scala.reflect.macros.Universe.Tree

    Permalink
  17. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  18. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  20. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  21. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped