Packages

trait MLValueWrapper[A <: MLValueWrapper[A]] extends FutureValue

Base trait to simplify creating classes that contain a reference to a value in the Isabelle process. Classes inheriting from this trait contain an MLValue that refers to a value in the Isabelle process. (That is, unless the inheriting class specifies further fields, this is the only data carried by the class. In particular, the class will not transfer data from the Isabelle process.)

Examples of classes based on MLValueWrapper are pure.Context, pure.Thm, pure.Position.

The minimal implementation of a class based on MLValueWrapper is as follows:

final class Something private (val mlValue: MLValue[Something]) extends MLValueWrapper[Something]

object Something extends MLValueWrapper.Companion[Something] {
  override protected val mlType: String = "Something"
  override protected def instantiate(mlValue: MLValue[Something]): Something = new Something(mlValue)
}

Here Something is the name of the Scala class that we want to implement, and something is the ML type of the corresponding values in the Isabelle process.

After importing Something.converter, the type Something can be transparently used to refer to something in the Isabelle process. E.g., MLValue.compileFunction[String,Something] or MLValue(st) for st of type Something or mlst.retrieveNow for mlst of type MLValue[Something].

The class Something may be customized in several ways:

  • By default, an ML value st : something is encoded as an exception (see the description of MLValue) as EXN st where EXN is an ML exception whose name is returned by Something.exceptionName. The name EXN is automatically chosen and the exception declared. If this is not desired, a different exception name can be provided by defining predefinedException in the companion object Something.
  • Arbitrary additional methods and fields can be added to the definition of the class Something or the companion object Something. However, it should be noted that the constructor of Something can only have arguments mlValue : MLValue[Something] and optionally an Isabelle instance and an ExecutionContext and not other user defined values. (This is because the constructor needs to be invoked by Something.instantiate which does not have access to other data.)
  • To implement functions that invoke ML code in the Isabelle process, it is recommended to place the compiled values inside an Ops class (see OperationCollection) in the companion object Something. Since the base trait MLValueWrapper.Companion already defines Ops, this needs to be done as follows:
override protected def newOps(implicit isabelle: Isabelle, ec: ExecutionContext): Ops = new Ops
protected class Ops(implicit isabelle: Isabelle, ec: ExecutionContext) extends super.Ops {
  // Example:
  lazy val test: MLFunction[Something,String] = compileFunction[Something,String]("... : something -> string")
}

The class Something represents an asynchronous value. That is, it is possible to have get an instance of Something even if the computation computing the corresponding ML value is still ongoing or has failed. To wait for that computation to terminate successfully, use the methods from FutureValue which Something inherits.

Note: Another possibility for defining wrapper classes for MLValues is AdHocConverter. Classes derived using AdHocConverter cannot be customized but only minimal boilerplate is needed.

Source
MLValueWrapper.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. MLValueWrapper
  2. FutureValue
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Abstract Value Members

  1. abstract val mlValue: MLValue[A]

    An MLValue referencing this (in the Isabelle process).

    An MLValue referencing this (in the Isabelle process). Since this is just a thin wrapper around an MLValue, mlValue carries exactly the same data as this and can be converted back and forth quickly (no transfer of data to/from the Isabelle process involved).

    Same as MLValue(this), assuming the correct MLValue.Converter from the companion object for A is imported.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def await: Unit

    Blocks until this future value is computed.

    Blocks until this future value is computed. (Or throws an exception if the computation fails.)

    Definition Classes
    MLValueWrapperFutureValue
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def force: MLValueWrapper.this.type

    Waits till the computation of this value (in the Isabelle process) has finished.

    Waits till the computation of this value (in the Isabelle process) has finished. (Or until an exception is thrown.)

    returns

    this value, but it is guaranteed to have completed the computation

    Definition Classes
    FutureValue
  10. def forceFuture(implicit ec: ExecutionContext): Future[MLValueWrapper.this.type]

    A future containing this object with the computation completed.

    A future containing this object with the computation completed. In particular, if this value throws an exception upon computation, the future holds that exception.

    Roughly the same as Future { this.force }.

    Definition Classes
    FutureValue
  11. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  15. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  16. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  17. def someFuture: Future[Any]

    Returns a future that completes when the computation of this object is complete.

    Returns a future that completes when the computation of this object is complete. (Or that holds an exception if that computation throws an exception.) However, upon successful completion, the future may return an arbitrary (and thus useless) value. May be faster to implement than forceFuture because there may be already a future available but that returns the wrong value.

    Definition Classes
    MLValueWrapperFutureValue
  18. def stateString: String

    A utility method that returns "" if this value was successfully computed, " (computing)" if it still computes, and " (failed)" if it finished with an exception.

    A utility method that returns "" if this value was successfully computed, " (computing)" if it still computes, and " (failed)" if it finished with an exception.

    This can be useful to constructing human readable messages about this value.

    Definition Classes
    FutureValue
  19. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  20. def toString(): String
    Definition Classes
    AnyRef → Any
  21. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  22. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  23. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

Inherited from FutureValue

Inherited from AnyRef

Inherited from Any

Ungrouped