Skip to content

Commit

Permalink
feat: Add concatenating SemiGroup for String and Enforce tests for Th…
Browse files Browse the repository at this point in the history
…ese (#252)
  • Loading branch information
MikuroXina authored Aug 5, 2024
1 parent c31e8ef commit 9d7e227
Show file tree
Hide file tree
Showing 3 changed files with 543 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/string.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { equal, greater, less, type Ordering } from "./ordering.ts";
import { fromCmp, type Ord } from "./type-class/ord.ts";
import { type SemiGroup, semiGroupSymbol } from "./type-class/semi-group.ts";

export const cmp = (lhs: string, rhs: string): Ordering => {
if (lhs === rhs) {
Expand All @@ -11,3 +12,11 @@ export const cmp = (lhs: string, rhs: string): Ordering => {
return greater;
};
export const ord: Ord<string> = fromCmp(() => cmp)();

/**
* A `SemiGroup` instance of concatenating `string`s.
*/
export const semiGroup: SemiGroup<string> = {
combine: (l, r) => l + r,
[semiGroupSymbol]: true,
};
Loading

0 comments on commit 9d7e227

Please sign in to comment.