Skip to content

Discrete vs Continuous quantities #14

Description

@davidrpugh

@bherd-rb Some tradable resources have quantities that are naturally discrete whilst other tradable resources have quantities that are natural continuous. I have been trying to come up with a solution to get this information into the type system. Getting this information into the type system is useful because it would allow us to restrict that types of orders that a particular auction can accept. For example, we might want to force market participants to only submit orders for discrete quantities (or continuous quantities).

I think that the Wurman et al (2001) paper provides a solution. Suppose that we have a trait Quantity that extends AnyVal and is parameterized on the type of value it contains. Then we can define two case classes for DiscreteQuantity and ContinuousQuantity as follows.

sealed trait Quantity[+T <: AnyVal] extends AnyVal {
  def value: T
}

case class DiscreteQuantity(value: Long) extends Quantity[Long]

case class ContinuousQuantity(value: Double) extends Quantity[Double]

Thoughts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions