Last active
November 25, 2015 12:29
-
-
Save dasch/314a836575376829e64c to your computer and use it in GitHub Desktop.
A type system for a stream processing framework
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- A user searched or changed to a new page of search results. | |
type Search = { query : SearchQuery, searchId : SearchId } | |
-- A user clicked a search result. | |
type Click = { searchId : SearchId, pageId : PageId } | |
-- A user viewed an article. | |
type PageView = { pageId : PageId } | |
type SearchQuery = String | |
type PageId = String | |
type SearchId = String | |
searches : Stream SessionId Search | |
clicks : Stream SessionId Click | |
pageviews : Stream SessionId PageView | |
searchClickThroughs : Stream SearchQuery PageId | |
searchClickThroughs = | |
let | |
searchClicks : Stream SearchId (Search, Click) | |
searchClicks = joinBy .searchId searches clicks | |
in | |
searchClicks | |
|> map (\(search, click) -> { query = search.query, pageId = click.pageId }) | |
|> keyBy .query | |
|> map .pageId |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment