flix

0.78.0

Counter

struct Counter[r: Eff]Source
mut state: Int32

Counter is a wrapper around Ref for a simple counter.

Its primary use is for generating identifiers.

Not thread-safe.

Type of simple mutable counters, and its functions.

Definitions

def fresh(rc: Region[r]): Counter[r] \ r§ Source

Returns a fresh Counter initialized to 0.

def get(counter: Counter[r]): Int32 \ r§ Source

Returns the state of counter.

def getAndIncrement(counter: Counter[r]): Int32 \ r§ Source

Returns the state of counter and increments it.

def increment(counter: Counter[r]): Unit \ r§ Source

Increments the state of counter.

def set(i: Int32, counter: Counter[r]): Unit \ r§ Source

Sets the state of counter to i.