SpaceLogic

trait SpaceLogic

abstract space logic

class Object
trait Matchable
class Any

Value members

Abstract methods

Is the type tp decomposable? i.e. all values of the type can be covered by its decomposed types.

Is the type tp decomposable? i.e. all values of the type can be covered by its decomposed types.

Abstract sealed class, OrType, Boolean and Java enums can be decomposed.

def covers(unapp: TermRef, scrutineeTp: Type): Boolean

Whether the extractor covers the given type

Whether the extractor covers the given type

def decompose(tp: Type): List[Space]

Get components of decomposable types

Get components of decomposable types

Return a space containing the values of both types.

Return a space containing the values of both types.

The types should be atomic (non-decomposable) and unrelated (neither should be a subtype of the other).

True if we can assume that the two unapply methods are the same. That is, given the same parameter, they return the same result.

True if we can assume that the two unapply methods are the same. That is, given the same parameter, they return the same result.

We assume that unapply methods are pure, but the same method may be called with different prefixes, thus behaving differently.

def isSubType(tp1: Type, tp2: Type): Boolean

Is tp1 a subtype of tp2?

Is tp1 a subtype of tp2?

def show(sp: Space): String

Display space in string format

Display space in string format

def signature(unapp: TermRef, scrutineeTp: Type, argLen: Int): List[Type]

Return term parameter types of the extractor unapp

Return term parameter types of the extractor unapp

Concrete methods

def dedup(spaces: Seq[Space])(using Context): Seq[Space]

Remove a space if it's a subspace of remaining spaces

Remove a space if it's a subspace of remaining spaces

Note: dedup will return the same result if the sequence >= 10

def flatten(space: Space)(using Context): Seq[Space]

Flatten space to get rid of Or for pretty print

Flatten space to get rid of Or for pretty print

def intersect(a: Space, b: Space)(using Context): Space

Intersection of two spaces

Intersection of two spaces

def isSubspace(a: Space, b: Space)(using Context): Boolean

Is a a subspace of b? Equivalent to a - b == Empty, but faster

Is a a subspace of b? Equivalent to a - b == Empty, but faster

def minus(a: Space, b: Space)(using Context): Space

The space of a not covered by b

The space of a not covered by b

def simplify(space: Space)(using Context): Space

Simplify space using the laws, there's no nested union after simplify

Simplify space using the laws, there's no nested union after simplify