Skip to content

Commit

Permalink
improve quality of comments
Browse files Browse the repository at this point in the history
  • Loading branch information
veigaribo committed Aug 19, 2022
1 parent bdcf355 commit 1003b59
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
8 changes: 1 addition & 7 deletions src/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ let idCounter = 0
* const monoid = new Class({
* name: 'Monoid',
* extends: [eq],
* laws: all(append, commutativity, associativity, identity)
* laws: all(append, associativity, identity)
* })
* ```
*
Expand Down Expand Up @@ -67,24 +67,18 @@ export class Class {
values: Generator<T>,
options: ValidationOptions = {},
): ValidationResult {
// check cache
if (cache.contains(Constructor, this)) {
return MaybeError.success()
}

// not cached
const result = MaybeError.foldConjoin([
// parents
...this.parents.map((parent) =>
parent.validate(Constructor, values, options),
),
// constructor itself
this.laws.check(Constructor, values, options),
])

// cache
cache.set(Constructor, this)

return result
}

Expand Down
6 changes: 3 additions & 3 deletions src/generators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Continuous<T extends Constructor> implements Generator<T> {
/**
*
* @param f A function from _n_ real numbers in the range [0, 1] to a value of
* T
* T.
* @param random A function that generates pseudo-random numbers. For each
* value that is instantiated, this function will be called with a different
* parameter `x`, and every random parameter will be a different `y`.
Expand Down Expand Up @@ -54,7 +54,7 @@ export class Discrete<T extends Constructor> implements Generator<T> {

/**
*
* @param values A list of discrete values the constructor may assume
* @param values A list of discrete values the constructor may assume.
*/
constructor(
public readonly values: InstanceType<T>[],
Expand Down Expand Up @@ -91,7 +91,7 @@ export function continuous<T extends Constructor>(
}

/**
* Generate testing values from a finite list
* Generate testing values from a finite list.
*
* @example
* ```
Expand Down
2 changes: 0 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,10 @@ export class MaybeError extends Maybe<string> {
}
}

// not very functional
isSuccess() {
return this.value === null
}

// not very functional
isError() {
return !this.isSuccess()
}
Expand Down

0 comments on commit 1003b59

Please sign in to comment.