Skip to content

Instantly share code, notes, and snippets.

@deque-blog
Last active March 9, 2018 10:02
Show Gist options
  • Save deque-blog/92625cd7684d497837679ac1be9c15a4 to your computer and use it in GitHub Desktop.
Save deque-blog/92625cd7684d497837679ac1be9c15a4 to your computer and use it in GitHub Desktop.
suggestedPostsFor userId = do
friendIds <- friendsOf userId -- Get the friends of the current user
topics <- favoriteTopicsOf userId -- Get the favorite topics of the current user
friendsPosts <- forM friendIds $ \friendId -> do -- For each friend
posts <- lastPostsOf friendId -- * Get their last posts
return (filter (isAbout topics) posts) -- * Keep those whose topic is relevant
return (mostLiked 3 friendsPosts) -- Rank them to keep only the bests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment