io.github.cakelier.tuples.space

Members list

Type members

Classlikes

object DSL

The object allowing the access to the DSL for creating JsonTupleTemplates.

The object allowing the access to the DSL for creating JsonTupleTemplates.

This objects contains all methods for creating a tuple template with simplicity and conciseness. The starting point are the complete and partial methods, to be used for allowing the creation of new JsonTupleTemplates. These are the only top-level templates allowed to be created. All other templates can be used as elements of this type of templates. An example of syntax using this DSL is:

complete(string in ("event-type-1", "event-type-2"), *, anyOf(bool, nil))

If a constant value is to be used for matching, it can be inserted as any other template in a tuple template, for example:

partial("event-type-1", 5.33f, *)

The use of this DSL is the main tool for creating new JsonTemplates of any kind, because it is able to limit the ways in which a template can be created. The API exposed by the JsonTemplate trait and all its subtypes it is not designed to capture the constraints of their creation or the use cases for this library, while this DSL is. Being so, it is highly encouraged to use DSL for creating templates.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
DSL.type
trait JsonSerializable[-A]

A type-class representing the operations that need to be supported by an object which can be serialized into a JSON-formatted string.

A type-class representing the operations that need to be supported by an object which can be serialized into a JSON-formatted string.

An object which can be serialized into a string using the JSON formatting needs to specify how to do so using a specific operation, which takes the object as input and returns a JSON-formatted string as output. Whether or not this function returns valid JSON, or JSON at all, is left to the right implementation of the function for the corresponding type of the object.

Type parameters

A

the type of the object that can be serialized in a JSON-formatted way

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Companion object to the JsonSerializable type-class, containing its interface and its implementations.

Companion object to the JsonSerializable type-class, containing its interface and its implementations.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
sealed trait JsonTemplate

A template, also known as an anti-tuple, an entity capable of matching against a tuple.

A template, also known as an anti-tuple, an entity capable of matching against a tuple.

Being the tuples "JSON" tuples, the templates should be "JSON" templates as well, being capable of matching them. This means that all the available templates are made for covering a different part of the "JSON Schema" specification, the only specification that can produce a JSON document which can be used for checking whether or not another JSON document conforms to it. This means that the JSON Schema allows to create templates for JSON documents, which can be matched against, the corresponding use case for this JSON template. Following the possible underlying representations of a JSON tuple and of an element of the tuple itself, a template can match against a null value, a boolean, an integer, a long integer, a single precision floating point number, a double precision floating point number, a string or a tuple itself. The JSON schema specification allows also for creating templates of templates, where the single templates are used for matching using different semantics. Then it can be possible to match a JSON element if any of the templates matches, if all of the templates matches, if only one of the templates matches. It is also possible to match a template if the inner template does not match.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
object JsonTemplate

The companion object to the JsonTemplate trait, containing its implementations.

The companion object to the JsonTemplate trait, containing its implementations.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
sealed trait JsonTuple

A tuple, an object representing an immutable and ordered sequence of values of different types.

A tuple, an object representing an immutable and ordered sequence of values of different types.

This implementation of a tuple is a "JSON" tuple, meaning that it is built on the fundamental concepts of the JSON format, enabling an easier exchange of data over the wire. This is because JSON is now the de-facto format for the data exchange on the web, which in turn is the standard for building distributed architectures, namely webservices. This means that a JSON tuple is the same concept as a JSON array, so an indexed sequence of values allowed in JSON, minus the "JSON object". Objects are not allowed since this would violate the rigid structure of a tuple: this would allow to objects to nest tuples inside them, which could nest other objects, which in turn could nest other tuples and so on and so forth. This would not correctly represent what in most programming languages is a sequence or list of elements. However, tuples can be nested into other tuples, enabling the equivalent of a matrix or of a jagged array. Their usefulness is in representing simple, not deeply nested data structures, such as messages or events exchanged in a distributed system.

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
Known subtypes
class #:
object JsonNil.type
object JsonTuple

Companion object to the JsonTuple trait, containing its factory methods and its implementations.

Companion object to the JsonTuple trait, containing its factory methods and its implementations.

Attributes

Companion
trait
Supertypes
trait Sum
trait Mirror
class Object
trait Matchable
class Any
Self type
JsonTuple.type
trait TupleOps[-T <: G, E, G]

A type-class representing the operations that must be supported by a tuple-like object.

A type-class representing the operations that must be supported by a tuple-like object.

Objects representing tuples, being so, must provide some operations that are expected to work on them. A tuple must allow to peek its internal structure in a predictable way, giving access to its number of elements, the elements at any given position, its head or its tail, to the initial part of it or the ending element. A tuple must also provide operations to update it, returning a new tuple, in a similar fashion to a sequence. So, elements can be appended, dropped, filtered, mapped, flat-mapped, taken, folded or an action can be performed for each one of them. At last, a tuple can be concatenated to another tuple, it can be converted to a Seq, existing a bijective relationship between them, split into two or zipped with another.

Type parameters

E

the concrete type of an element in the tuple

G

the abstract type of tuple to which the concrete type belongs

T

the concrete type of tuple that must support these operations

Attributes

Companion
object
Supertypes
class Object
trait Matchable
class Any
object TupleOps

Companion object to the TupleOps type-class, containing the type-class interface and the implementation for the JsonTuple type.

Companion object to the TupleOps type-class, containing the type-class interface and the implementation for the JsonTuple type.

Attributes

Companion
trait
Supertypes
class Object
trait Matchable
class Any
Self type
TupleOps.type

Types

type JsonElement = Int | Long | Double | Float | Boolean | String | JsonTuple | Null

A JSON element, an admissible element in the JSON specification.

A JSON element, an admissible element in the JSON specification.

This type represents an element in the JSON specification, such as an integer number, a long integer number, a floating point single precision number, a floating point double precision number, a boolean value, a string value, a null value or a JsonTuple. This last type is needed because not only this type is of a JSON element, it is also the type of all elements that can be contained into a JsonTuple. In this way, the JsonTuples can be nested one inside the other, because an element in a tuple can be another tuple. Being so, a JSON element can also be a JSON array, because a JSON tuple is just that, but not a JSON object. Objects are not allowed since this would violate the rigid structure of a tuple: this would allow to objects to nest tuples inside them, which could nest other objects, which in turn could nest other tuples and so on and so forth. This would not correctly represent what in most programming languages is a sequence or list of elements.

Attributes

Exports

Defined exports

final type #: = #:
Exported from JsonTuple$
def *: Template
Exported from DSL

Returns a new "any" template, capable of matching any JsonElement.

Returns a new "any" template, capable of matching any JsonElement.

Attributes

Exported from JsonTemplate
Exported from JsonTemplate
Exported from JsonTemplate
Exported from JsonTemplate
Exported from JsonTemplate
Exported from JsonTemplate
Exported from JsonTemplate
Exported from JsonTemplate$
Exported from JsonTemplate
Exported from JsonTemplate$
final val JsonNil: JsonNil.type
Exported from JsonTuple
Exported from JsonTemplate
Exported from JsonTemplate$
Exported from JsonTemplate
Exported from JsonTemplate
Exported from JsonTemplate
Exported from JsonTemplate
Exported from JsonTemplate
def bool: Template
Exported from DSL

Returns a new "boolean" template, capable of matching any Boolean value.

Returns a new "boolean" template, capable of matching any Boolean value.

Attributes

Exported from DSL

Returns a new "double" template, capable of matching any Double value.

Returns a new "double" template, capable of matching any Double value.

Attributes

Exported from DSL

Returns a new "float" template, capable of matching any Float value.

Returns a new "float" template, capable of matching any Float value.

Attributes

Exported from DSL

Returns a new "integer" template, capable of matching any Int value.

Returns a new "integer" template, capable of matching any Int value.

Attributes

Exported from DSL

Returns a new "long" template, capable of matching any Long value.

Returns a new "long" template, capable of matching any Long value.

Attributes

def nil: Template
Exported from DSL

Returns a new "null" template, capable of matching only the null value.

Returns a new "null" template, capable of matching only the null value.

Attributes

Exported from DSL

Returns a new "string" template, capable of matching any String value.

Returns a new "string" template, capable of matching any String value.

Attributes