Header menu logo issie

Helpers Module

Nested modules

Modules Description

JsonHelpers

PrintSimple

Functions to print human-readable version of CanvasState

ReduceKeys

Take a project and compress all of the IDs.

RegenerateIds

Give every component, port and connection on one sheet a fresh uuid, rewriting every reference to the old ones. Used when a sheet is copied (Import / Duplicate Sheet), and to repair projects in which two sheets were given the same ids by an earlier copy. Ids are unique within a sheet only, but a few places (waveform sheet labels, wire highlighting) assume they are unique across the whole project.

ResultList

Running a list of operations that can fail, stopping at the first Error. Written out by hand this is a fold over Result whose accumulator is built with `got @ [x]`, which is quadratic and was repeated in half a dozen places. These are linear and are the only version.

Functions and values

Function or value Description

assertThat cond msg

Full Usage: assertThat cond msg

Parameters:
    cond : bool
    msg : string

cond : bool
msg : string

clearIdentityMemos ()

Full Usage: clearIdentityMemos ()

Parameters:
    () : unit

Empty every memoizeByIdentity memo, releasing whatever their keys and values hold on to. Call where something large is discarded rather than replaced - a simulation being ended. Doing so is always safe: a memo is only ever an answer that can be worked out again, so the cost of emptying one that was still wanted is that it is filled again on the next call.

() : unit

cropToLength len fromStart str

Full Usage: cropToLength len fromStart str

Parameters:
    len : int
    fromStart : bool
    str : string

Returns: string

Crop a string to the specified length. fromStart indicates whether you want the first characters or the last characters.

len : int
fromStart : bool
str : string
Returns: string

getCustomComponentType _arg1

Full Usage: getCustomComponentType _arg1

Parameters:
Returns: CustomComponentType
_arg1 : ComponentType
Returns: CustomComponentType

getCustomName _arg1

Full Usage: getCustomName _arg1

Parameters:
Returns: string
_arg1 : ComponentType
Returns: string

getMemData address memData

Full Usage: getMemData address memData

Parameters:
    address : bigint
    memData : Memory1

Returns: bigint
address : bigint
memData : Memory1
Returns: bigint

isCustom _arg1

Full Usage: isCustom _arg1

Parameters:
Returns: bool
_arg1 : ComponentType
Returns: bool

isIOLabel _arg1

Full Usage: isIOLabel _arg1

Parameters:
Returns: bool
_arg1 : ComponentType
Returns: bool

isInput _arg1

Full Usage: isInput _arg1

Parameters:
Returns: bool
_arg1 : ComponentType
Returns: bool

isOutput _arg1

Full Usage: isOutput _arg1

Parameters:
Returns: bool
_arg1 : ComponentType
Returns: bool

isViewer _arg1

Full Usage: isViewer _arg1

Parameters:
Returns: bool
_arg1 : ComponentType
Returns: bool

listSet lst item idx

Full Usage: listSet lst item idx

Parameters:
    lst : 'a list
    item : 'a
    idx : int

Returns: 'a list

Set an element of the list at the specified position. This function is slow: O(n). Do not use unless necessary.

lst : 'a list
item : 'a
idx : int
Returns: 'a list

mapFindWithDef defVal key map

Full Usage: mapFindWithDef defVal key map

Parameters:
    defVal : 'b
    key : 'a
    map : Map<'a, 'b>

Returns: 'b
Modifiers: inline
Type parameters: 'b, 'a

Look up key in map, return defVal if key is not found

defVal : 'b
key : 'a
map : Map<'a, 'b>
Returns: 'b

mapInverse m

Full Usage: mapInverse m

Parameters:
    m : Map<'A, 'B>

Returns: Map<'B, 'A>
Modifiers: inline
Type parameters: 'A, 'B

create inverse map

m : Map<'A, 'B>
Returns: Map<'B, 'A>

mapKeys map

Full Usage: mapKeys map

Parameters:
    map : Map<'a, 'b>

Returns: 'a array
Modifiers: inline
Type parameters: 'a, 'b

Array of map keys

map : Map<'a, 'b>
Returns: 'a array

mapPair f (arg2, arg3)

Full Usage: mapPair f (arg2, arg3)

Parameters:
    f : 'S -> 'T
    arg1 : 'S
    arg2 : 'S

Returns: 'T * 'T
Modifiers: inline
Type parameters: 'S, 'T

Map a function over a pair of elements. mapPair f (x,y) = f x, f y.

f : 'S -> 'T
arg1 : 'S
arg2 : 'S
Returns: 'T * 'T

mapUnion m1 m2

Full Usage: mapUnion m1 m2

Parameters:
    m1 : Map<'a, 'b>
    m2 : Map<'a, 'b>

Returns: Map<'a, 'b>
Modifiers: inline
Type parameters: 'a, 'b

Union of maps, common keys take m1 value

m1 : Map<'a, 'b>
m2 : Map<'a, 'b>
Returns: Map<'a, 'b>

mapUpdateWithDef defVal update key map

Full Usage: mapUpdateWithDef defVal update key map

Parameters:
    defVal : 'b
    update : 'b -> 'b
    key : 'a
    map : Map<'a, 'b>

Returns: Map<'a, 'b>
Modifiers: inline
Type parameters: 'b, 'a

If key exists in map: (key:v) -> (key:update v), otherwise create new item (key : update v)

defVal : 'b
update : 'b -> 'b
key : 'a
map : Map<'a, 'b>
Returns: Map<'a, 'b>

mapValues map

Full Usage: mapValues map

Parameters:
    map : Map<'a, 'b>

Returns: 'b array
Modifiers: inline
Type parameters: 'a, 'b

Array of map values

map : Map<'a, 'b>
Returns: 'b array

memoizeBy keyFunc funcToMemoize

Full Usage: memoizeBy keyFunc funcToMemoize

Parameters:
    keyFunc : 'a -> 'k
    funcToMemoize : 'a -> 'c

Returns: 'a -> 'c

Return a memoized version of funcToMemoize where. Repeated calls with equivalent inputs return a stored result. Inputs a, a' are deemed equivalent if keyFunc a = keyFunc a'. Use this as well as LazyView etc, it has a different usage since it need not have React output and comparison is via a key function.

keyFunc : 'a -> 'k
funcToMemoize : 'a -> 'c
Returns: 'a -> 'c

memoizeByIdentity funcToMemoize

Full Usage: memoizeByIdentity funcToMemoize

Parameters:
    funcToMemoize : 'a -> 'b

Returns: 'a -> 'b
funcToMemoize : 'a -> 'b
Returns: 'a -> 'b

nocr s

Full Usage: nocr s

Parameters:
    s : string

Returns: string

replace new lines in a string by ';' for easier debug printing of records using %A

s : string
Returns: string

pow2 exponent

Full Usage: pow2 exponent

Parameters:
    exponent : int

Returns: int

Return 2^exponent.

exponent : int
Returns: int

shortPComp comp

Full Usage: shortPComp comp

Parameters:
Returns: string
comp : Component
Returns: string

sprintInitial n s

Full Usage: sprintInitial n s

Parameters:
    n : int
    s : string

Returns: string

return initial n characters of a string

n : int
s : string
Returns: string

swapArrayEls i1 i2 arr

Full Usage: swapArrayEls i1 i2 arr

Parameters:
    i1 : int
    i2 : int
    arr : 'a[]

Returns: 'a array

Returns a new array with the elements at index i1 and index i2 swapped

i1 : int
i2 : int
arr : 'a[]
Returns: 'a array

testMatch diffX diffY normRot

Full Usage: testMatch diffX diffY normRot

Parameters:
    diffX : float
    diffY : float
    normRot : int

Returns: float list
diffX : float
diffY : float
normRot : int
Returns: float list

Type something to start searching.