Ludwig.NodeStream

This module allows you to work with the ‘NodeStream’. This is an advanced Ludwig concept that holds the entire output. By having access to the entire output, it is possible to write validations accross values and types.

Module Members

lookupNodeByValue

(Function)

If you only have the ‘value’ of a ‘Node’, you can use this to look up other details such as the ID and the tag.

Type Signature

 fun (NodeStream, a) -> Optional<Node<a>>
Argument: ns
Type: NodeStream
Argument: value
Type: a
Returns:
Type: Optional<Node<a>>

unsafeAddMetaAnnotation

(Function)

This function allows you put arbitrary annotations on Ludwig resources (sum type values). These annotations will then be present in the final NodeStream.

These annotations are similar to annotations in ludwig files, e.g.: @mutable, @proto(2), but re-ified on Ludwig values and tracked during execution.

Type Signature

 fun { name: String,
       arguments: Optional<List<String>>,
       value: a} -> a
Argument: name
Type: String
Argument: arguments
Type: Optional<List<String>>
Argument: value
Type: a
Returns:
Type: a

unsafeCopyAnnotations

(Function)

This function allows you take all annotations on src and add them to dst. This creates a new dst value.

Type Signature

 fun (a, b) -> b
Argument: src

Source of the annotations.

Type: a

Argument: dst

Destination to copy the annotations to.

Type: b

Returns:
Type: b

unsafeGetNodesByTag

(Function)

Get all nodes of a certain type (tag) from the ‘NodeStream’.

The tag is the concatenation of the module name and the type name. This is the same as the “fully qualified” type name.

Example:

subnets: unsafeGetNodesByTag(ns, 'Fugue.Core.AWS.EC2.Subnet')

Type Signature

 fun (NodeStream, String) -> List<Node<a>>
Argument: ns

The nodestream

Type: NodeStream

Argument: tag

Tag of the types you want to obtain

Type: String

Returns:

List of nodes of the requested type

Type: List<Node<a>>

valuesEqual

(Function)

This function checks that both x and y are node values, and that they are in fact the same node. You can use this to compare the value of two Nodes or to compare arbitrary types that are supposed to be nodes.

If x or y are not nodes, then this function will return False.

Example:

foo:
  let subnet: Subnet.new {...}
  NodeStream.valuesEqual(subnet, subnet)  # => True

Note a node:

bar: NodeStream.valuesEqual(1, 1)  # => False

Type Signature

 fun (a, a) -> Bool
Argument: x

First node to compare

Type: a

Argument: y

Second node to compare

Type: a

Returns:

Whether or not the two nodes are one and the same

Type: Bool

Node

(Type)

type Node<a>:
  id: String
  tag: String
  value: a

A ‘Node’ is a single entry in the ‘NodeStream’.

Record {

Field: id
Type: String
Field: tag
Type: String
Field: value
Type: a

}

NodeStream

(Type)

type opaque NodeStream

The ‘NodeStream’ is an advanced Ludwig concept that holds the entire output of the compiler. It is possible to write validations for this type.