Skip to content
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

Repeatedly func #78

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

EncodePanda
Copy link
Contributor

repeatedly returns one more time a function value (instead of being a method).

also added ginterpret

@CLAassistant
Copy link

CLAassistant commented Apr 11, 2017

CLA assistant check
All committers have signed the CLA.

@@ -681,8 +681,8 @@ package object matryoshka {
*
* @group algtrans
*/
@tailrec
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like this to be a function, but the problem is that we need this to be tail recursive.

We could actually rewrite this as a coalgebra, like:

final def repeatedlyƒ[A](f: A => Option[A]): Coalgebra[A \/ ?, A] = f(expr) \/> expr

final def repeatedly[A](f: A => Option[A]): A => A =
  _.ana[Nu](repeatedlyƒ(f)).unsafePerformSync

We have some stack-safety tests of Partial that make me think this works, although no performance promises.

But then maybe we can rewrite stuff to use repeatedlyƒ instead of repeatedly, and track partiality through more of the code.

@edmundnoble – thoughts?

@@ -54,6 +54,9 @@ package object patterns {
AlgebraM[M, CoEnv[A, F, ?], B] =
ginterpretM[Id, M, F, A, B](f, φ)

def ginterpret[W[_], F[_], A, B](f: A => Id[B], φ: GAlgebra[W, F, B]): GAlgebra[W, CoEnv[A, F, ?], B] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏾

@sellout
Copy link
Contributor

sellout commented Jun 2, 2017

So, Matryoshka has a new definition of repeatedly now that basically requires it to return Partial[A], tracking the general recursion explicitly, so if this PR (including the description) could be updated to only have ginterpret in it, that’d be great, and we can get it merged and gone.

@EncodePanda
Copy link
Contributor Author

👍 but Monday after spark summit

@sellout
Copy link
Contributor

sellout commented Jun 8, 2017

@rabbitonweb Ping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants