Skip to content

Repeatedly func#78

Open
EncodePanda wants to merge 2 commits intoprecog:masterfrom
EncodePanda:repeatedly_func
Open

Repeatedly func#78
EncodePanda wants to merge 2 commits intoprecog:masterfrom
EncodePanda:repeatedly_func

Conversation

@EncodePanda
Copy link
Copy Markdown
Contributor

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

also added ginterpret

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 11, 2017

CLA assistant check
All committers have signed the CLA.

*
* @group algtrans
*/
@tailrec
Copy link
Copy Markdown
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?

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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👍🏾

@sellout
Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

👍 but Monday after spark summit

@sellout
Copy link
Copy Markdown
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.

3 participants