Skip to content

Instantly share code, notes, and snippets.

@kaja47
Last active December 20, 2015 07:58
Show Gist options
  • Select an option

  • Save kaja47/6096920 to your computer and use it in GitHub Desktop.

Select an option

Save kaja47/6096920 to your computer and use it in GitHub Desktop.
You almost can do this in PHP, almost.
<?php
// generators are weaker than monads and this is therefore not possible
// CPS transformation to state machines sucks balls
$usersWhoCommentedOnTheirPosts = run($seqMonad, function () {
$user = (yield allUsers());
$post = (yield $user->posts);
$comm = (yield $post->comments);
if ($comm->author === $comm->author)
yield [$user, $post, $comm];
});
// same thing in Scala look pretty much the same
val usersWhoCommentedOnTheirVisiblePosts = for {
user <- allUsers
post <- user.posts
comm <- post.comments
if comm.author == comm.author
} yield (user, post, comm)
@kaja47
Copy link
Copy Markdown
Author

kaja47 commented Jul 28, 2013

Real men don't test their code. Really real men don't even compile their code.

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