-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add GCursor
and KLens
types for traversing data with history
#15
base: master
Are you sure you want to change the base?
Conversation
…rade cats and scala-js.
|
||
implicit def eqCursorHistory[A]: Eq[CursorHistory[A]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there was never an A ?
* @tparam NewValue The type of the new value | ||
* @param NewFocus The type of the new focus | ||
*/ | ||
final type Next[NewValue, NewFocus] = GCursor.AuxL[T, NewValue, NewFocus, Self] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
starting to look like profunctor optics
CursorHistory(history, Some(NonEmptyVector.of(failedOp))) | ||
|
||
@inline final private def id[B](b: B): Id[B] = b | ||
@inline final private def dup[B](b: B): Id[(B, B)] = (b, b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is 1/2 monoid and 1/2 comonoid - worth thinking about b/c those are precursors to monad/comonad if you don't have either already
|
||
lazy val root: GCursor.Top[T] = self.root | ||
lazy val focus: NewFocus = newFocus | ||
lazy val last: Option[GCursor.AuxL[T, A, self.Focus, self.Last]] = Some(self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wild
* @param ev Evidence that the current focus is a `(List[A], Int)` | ||
* @see def moveList | ||
*/ | ||
final def rightN(n: Int)(implicit ev: Focus =:= (List[A], Int)): Either[CursorHistory, Next[A, (List[A], Int)]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking like a zipper. comonad
* @param ev Evidence that the current focus is a `List[B]` | ||
* @return A new cursor focused on the first element in the list, `None` if the list was empty | ||
*/ | ||
final def downArray[B](implicit ev: A =:= List[B]): Either[CursorHistory, Next[B, (List[B], Int)]] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😮
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to see you keeping forward motion, this is some rare-air code
No description provided.