aboutsummaryrefslogtreecommitdiff
path: root/src/eval/index.ts
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2022-01-14 19:10:49 +0530
committerAkshay Nair <phenax5@gmail.com>2022-01-14 19:23:59 +0530
commitb5893d68ce4eacbc3ae431ca48f821657236c7aa (patch)
tree3bf215c9ff226fbe1363069fcc63ca22ea5417c7 /src/eval/index.ts
parentde5d3de99afae3cb7f1dc56fe8781394f8614a50 (diff)
downloadelxr-b5893d68ce4eacbc3ae431ca48f821657236c7aa.tar.gz
elxr-b5893d68ce4eacbc3ae431ca48f821657236c7aa.zip
refactor: refactors imports + formatting
Diffstat (limited to 'src/eval/index.ts')
-rw-r--r--src/eval/index.ts28
1 files changed, 10 insertions, 18 deletions
diff --git a/src/eval/index.ts b/src/eval/index.ts
index 3bf0290..f56ff92 100644
--- a/src/eval/index.ts
+++ b/src/eval/index.ts
@@ -1,16 +1,8 @@
import { identity, pipe } from 'fp-ts/function'
-import { filter, takeLeftWhile, zip, zipWith } from 'fp-ts/lib/Array'
-import {
- chain,
- getOrElseW,
- isSome,
- map,
- none,
- Option,
- some,
-} from 'fp-ts/lib/Option'
-import { Expr, ListExpr, Literal } from '../types'
-import { jlog, match } from '../utils'
+import { filter, takeLeftWhile, zip, zipWith } from 'fp-ts/Array'
+import * as Option from 'fp-ts/Option'
+import { Expr, ListExpr } from '../types'
+import { match } from '../utils'
export interface MatchGroupIndexed<T = any> {
value: T
@@ -73,20 +65,20 @@ const checkExpr = <T>(
(acc, exp) =>
pipe(
acc,
- chain(ac =>
+ Option.chain(ac =>
pipe(
checkExpr(exp, item, list, index, localSkip),
zip(ac),
z => z.map(([res, _cur]) => res),
- z => (z.length === 0 ? none : some(z)),
+ z => (z.length === 0 ? Option.none : Option.some(z)),
),
),
),
- some(checkExpr(head, item, list, index, localSkip)),
+ Option.some(checkExpr(head, item, list, index, localSkip)),
)
return pipe(
matches,
- getOrElseW(() => []),
+ Option.getOrElseW(() => []),
skip(Math.max(...getSkips()) || 1),
)
},
@@ -103,12 +95,12 @@ const checkExpr = <T>(
Object.prototype.hasOwnProperty.call(item ?? {}, name)
? checkExpr(expr, item[name], list, index)
: [],
- res => (res.length > 0 ? [group(item, index)] : []), // FIXME: doesn't allow nested matching
+ res => (res.length > 0 ? [group(item, index)] : []), // TODO: doesn't allow nested matching
skip(1),
),
OneOrMore: ({ expr }) => {
- // TODO: Nested quantified expression
+ // TODO: Nested quantified expressions?
const matches = pipe(
list,
takeLeftWhile(a => checkExpr(expr, a, list, index).length > 0),