Adding basic search to the text editor

This commit is contained in:
Dustin Swan 2026-04-05 20:42:52 -06:00
parent 8e05690ef3
commit 4a62774a57
No known key found for this signature in database
GPG key ID: 30D46587E2100467
3 changed files with 131 additions and 15 deletions

View file

@ -79,6 +79,14 @@ export const _rt = {
return String(value);
},
chars: (s: string) => s.split(''),
strIndexOf: (needle: string) => (haystack: string) => (start: number) => {
const i = haystack.indexOf(needle, start);
return i === -1 ? { _tag: 'None' } : { _tag: 'Some', _0: i };
},
strLastIndexOf: (needle: string) => (haystack: string) => {
const i = haystack.lastIndexOf(needle);
return i === -1 ? { _tag: 'None' } : { _tag: 'Some', _0: i };
},
isWordChar: (s: string) => ({ _tag: /^\w$/.test(s) ? 'True' : 'False' }),
// join: (delim: string) => (xs: string[]) => xs.join(delim),
split: (delim: string) => (xs: string) => xs.split(delim),