Last active
February 8, 2019 08:41
-
-
Save paulvictor/c7d25b42e76799311726140aafa83a9f to your computer and use it in GitHub Desktop.
Translation of the latency function
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
| pgLatency :: Array Page -> Array Event -> Int | |
| pgLatency pages events = | |
| snd <<< | |
| runState | |
| (for_ | |
| (pagesAndEventsSortedOnTime | |
| (either | |
| \p -> whenM ((\s -> fst s && isUsefulPage p) <$> get) (modify_ (snd >>> _ + p.latency)) | |
| \e -> whenM ((\s -> fst s && isUsefulEvent e) <$> get) (modify_ (fst >>> const true))) | |
| ) | |
| ) ( false /\ 0) | |
| where | |
| pagesAndEventsSortedOnTime = | |
| sortWith | |
| (_.at ||| _.at) | |
| ((Left <$> pages) <> (Right <$> events)) | |
| isUsefulPage p = | |
| fromMaybe false $ | |
| ((elem _ pgUrlList) <$> p.url) <|> ((elem _ pgTitleList) <$> p.title) | |
| isUsefulEvent e = | |
| fromMaybe false $ | |
| ((elem _ eTrigger) <$> e.value) <|> ((elem _ pTrigger) <$> e.title) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment