Skip to content

Commit

Permalink
refactor: rename parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Dec 15, 2023
1 parent 8bd1b2d commit c83d36a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/common/maybe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Reference documentation https://gigobyte.github.io/purify/adts/Maybe
// ISC licensed https://github.com/gigobyte/purify/blob/0840eb69b97617b09aca098f73948c61de563194/LICENSE

export type Maybe<T extends {}> = IMaybe<T>

export interface IMaybe<T extends {}> {
isJust: () => boolean
isNothing: () => boolean
Expand All @@ -18,8 +20,6 @@ export interface IMaybe<T extends {}> {
ifNothing: (f: () => void) => this
}

export type Maybe<T extends {}> = IMaybe<T>

export const Just = <T extends {}>(value: T): IMaybe<T> => {
const instance: IMaybe<T> = {
isJust: () => true,
Expand Down
8 changes: 4 additions & 4 deletions src/features/editor/codemirror/highlightLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export const HighlightLineEffect = StateEffect.define<{
pos: Maybe<number>
filter?: RangeSetUpdateFilter<Decoration>
}>({
map({ pos: pos_M, filter }, change) {
map({ pos: maybePos, filter }, change) {
return {
pos: pos_M.map((pos) => change.mapPos(pos)),
pos: maybePos.map((pos) => change.mapPos(pos)),
filter,
}
},
Expand Down Expand Up @@ -52,9 +52,9 @@ const highlightLineField = StateField.define<DecorationSet>({
)
return filterEffects(transaction.effects, HighlightLineEffect).reduce(
(resultDecorations, effect) =>
mapEffectValue(effect, ({ pos: pos_M, filter }) =>
mapEffectValue(effect, ({ pos: maybePos, filter }) =>
resultDecorations.update({
add: pos_M
add: maybePos
.map((pos) => {
const hasOverlappedSelection = hasNonEmptySelectionAtLine(
transaction.state.doc.lineAt(pos),
Expand Down
8 changes: 4 additions & 4 deletions src/features/editor/codemirror/wavyUnderline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ export const WavyUnderlineEffect = StateEffect.define<{
range: Maybe<{ from: number; to: number }>
filter?: RangeSetUpdateFilter<Decoration>
}>({
map({ range: range_M, filter }, change) {
map({ range: maybeRange, filter }, change) {
return {
range: range_M.map(({ from, to }) => ({
range: maybeRange.map(({ from, to }) => ({
from: change.mapPos(from),
to: change.mapPos(to),
})),
Expand All @@ -32,9 +32,9 @@ const wavyUnderlineField = StateField.define<DecorationSet>({
const decorations = __decorations.map(transaction.changes)
return filterEffects(transaction.effects, WavyUnderlineEffect).reduce(
(resultDecorations, effect) =>
mapEffectValue(effect, ({ range: range_M, filter }) =>
mapEffectValue(effect, ({ range: maybeRange, filter }) =>
resultDecorations.update({
add: range_M.map(({ from, to }) => [markDecoration.range(from, to)]).extract(),
add: maybeRange.map(({ from, to }) => [markDecoration.range(from, to)]).extract(),
filter,
}),
),
Expand Down
12 changes: 6 additions & 6 deletions src/features/editor/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ const underlineAssemblerError = defineViewEffect((view) => {
return observe(
assemblerErrorRange$.pipe(
map(Maybe.fromNullable),
map((range_M) =>
map((maybeRange) =>
WavyUnderlineEffect.of({
range: range_M,
filter: () => range_M.isJust(),
range: maybeRange,
filter: () => maybeRange.isJust(),
}),
),
map((effect) => ({ effects: effect })),
Expand All @@ -111,8 +111,8 @@ const underlineAssemblerError = defineViewEffect((view) => {

const highlightLineWithStatement = defineViewEffect((view) => {
const statementLinePos$ = store.onState(curryRight2(selectCurrentStatementLinePos)(view))
return observe(statementLinePos$, (linePos_M) => {
linePos_M
return observe(statementLinePos$, (maybeLinePos) => {
maybeLinePos
.map((linePos) =>
linePos.map((pos, posIndex) =>
HighlightLineEffect.of({
Expand All @@ -133,7 +133,7 @@ const highlightLineWithStatement = defineViewEffect((view) => {
.map((effects) => ({ effects }))
.ifJust((transaction) => view.dispatch(transaction))

linePos_M
maybeLinePos
.filter(() => !view.hasFocus)
.map((linePos) => ({
// length of `linePos` is already checked
Expand Down

0 comments on commit c83d36a

Please sign in to comment.