add internals doc

This commit is contained in:
Felix Roos 2023-01-11 22:48:47 +01:00
parent a120a9895b
commit d5f37e2cbe
3 changed files with 202 additions and 4 deletions

View File

@ -39,8 +39,11 @@ export class Pattern {
/**
* Returns a new pattern, with the function applied to the value of
* each hap. It has the alias {@link Pattern#fmap}.
* @param {Function} func
* @synonyms fmap
* @param {Function} func to to apply to the value
* @returns Pattern
* @example
* "0 1 2".withValue(v => v + 10).log()
*/
withValue(func) {
return new Pattern((state) => this.query(state).map((hap) => hap.withValue(func)));
@ -53,10 +56,15 @@ export class Pattern {
return this.withValue(func);
}
/**
* Assumes 'this' is a pattern of functions, and given a function to
* resolve wholes, applies a given pattern of values to that
* pattern of functions.
* @param {Function} whole_func
* @param {Function} func
* @returns Pattern
*/
appWhole(whole_func, pat_val) {
// Assumes 'this' is a pattern of functions, and given a function to
// resolve wholes, applies a given pattern of values to that
// pattern of functions.
const pat_func = this;
const query = function (state) {
const hap_funcs = pat_func.query(state);

View File

@ -74,6 +74,7 @@ export const SIDEBAR: Sidebar = {
{ text: 'REPL', link: 'technical-manual/repl' },
{ text: 'Docs', link: 'technical-manual/docs' },
{ text: 'Testing', link: 'technical-manual/testing' },
{ text: 'Internals', link: 'technical-manual/internals' },
],
},
};

View File

@ -0,0 +1,189 @@
---
title: Internals
layout: ../../layouts/MainLayout.astro
---
import { MiniRepl } from '../../docs/MiniRepl';
import { JsDoc } from '../../docs/JsDoc';
# Internal Functions
These functions are more low level, probably not needed by the live coder.
# Haskell-style functor, applicative and monadic operations
## withValue
<JsDoc client:idle name="Pattern#withValue" h={0} />
## appWhole
<JsDoc client:idle name="Pattern#appWhole" h={0} />
## appBoth
<JsDoc client:idle name="Pattern#appBoth" h={0} />
## appLeft
<JsDoc client:idle name="Pattern#appLeft" h={0} />
## appRight
<JsDoc client:idle name="Pattern#appRight" h={0} />
## bindWhole
<JsDoc client:idle name="Pattern#bindWhole" h={0} />
## bind
<JsDoc client:idle name="Pattern#bind" h={0} />
## join
<JsDoc client:idle name="Pattern#join" h={0} />
## outerBind
<JsDoc client:idle name="Pattern#outerBind" h={0} />
## outerJoin
<JsDoc client:idle name="Pattern#outerJoin" h={0} />
## innerBind
<JsDoc client:idle name="Pattern#innerBind" h={0} />
## innerJoin
<JsDoc client:idle name="Pattern#innerJoin" h={0} />
## trigJoin
<JsDoc client:idle name="Pattern#trigJoin" h={0} />
## trigzeroJoin
<JsDoc client:idle name="Pattern#trigzeroJoin" h={0} />
## squeezeJoin
<JsDoc client:idle name="Pattern#squeezeJoin" h={0} />
## squeezeBind
<JsDoc client:idle name="Pattern#squeezeBind" h={0} />
# Utility methods mainly for internal use
## queryArc
<JsDoc client:idle name="Pattern#queryArc" h={0} />
## splitQueries
<JsDoc client:idle name="Pattern#splitQueries" h={0} />
## withQuerySpan
<JsDoc client:idle name="Pattern#withQuerySpan" h={0} />
## withQuerySpanMaybe
<JsDoc client:idle name="Pattern#withQuerySpanMaybe" h={0} />
## withQueryTime
<JsDoc client:idle name="Pattern#withQueryTime" h={0} />
## withHapSpan
<JsDoc client:idle name="Pattern#withHapSpan" h={0} />
## withHapTime
<JsDoc client:idle name="Pattern#withHapTime" h={0} />
## withHaps
<JsDoc client:idle name="Pattern#withHaps" h={0} />
## withHap
<JsDoc client:idle name="Pattern#withHap" h={0} />
## setContext
<JsDoc client:idle name="Pattern#setContext" h={0} />
## withContext
<JsDoc client:idle name="Pattern#setContext" h={0} />
## stripContext
<JsDoc client:idle name="Pattern#stripContext" h={0} />
## withLocation
<JsDoc client:idle name="Pattern#withLocation" h={0} />
## withMiniLocation
<JsDoc client:idle name="Pattern#withMiniLocation" h={0} />
## filterHaps
<JsDoc client:idle name="Pattern#filterHaps" h={0} />
## filterValues
<JsDoc client:idle name="Pattern#filterValues" h={0} />
## removeUndefineds
<JsDoc client:idle name="Pattern#filterValues" h={0} />
## onsetsOnly
<JsDoc client:idle name="Pattern#onsetsOnly" h={0} />
## discreteOnly
<JsDoc client:idle name="Pattern#discreteOnly" h={0} />
## defragmentHaps
<JsDoc client:idle name="Pattern#defragmentHaps" h={0} />
## firstCycle
<JsDoc client:idle name="Pattern#firstCycle" h={0} />
## firstCycleValues
<JsDoc client:idle name="Pattern#firstCycleValues" h={0} />
## showFirstCycle
<JsDoc client:idle name="Pattern#showFirstCycle" h={0} />
## sortHapsByPart
<JsDoc client:idle name="Pattern#sortHapsByPart" h={0} />
## asNumber
<JsDoc client:idle name="Pattern#sortHapsByPart" h={0} />
# Operators
- \_opIn
- \_opOut
- \_opMix
- \_opSqueeze
- \_opSqueezeOut
- \_opTrig
- \_opTrigzero