<commit_before>
module Ivory.Tower.AST.System
  ( System(..)
  , event_emitters
  , poll_receivers
  , event_receivers
  ) where

import Ivory.Tower.AST.Chan
import qualified Ivory.Tower.AST.Directory as D
import Ivory.Tower.AST.Task
import Ivory.Tower.AST.ChanEmitter
import Ivory.Tower.AST.ChanReceiver
import Ivory.Tower.Types.Unique

data System =
  System
    { system_channels :: [Chan]
    , system_tasks    :: D.Dir Unique Task
    } deriving (Eq, Show)

event_emitters :: System -> Chan -> [(ChanEmitter, Task)]
event_emitters sys chan = error "Tower.AST.System.event_emitters undefined" -- XXX

poll_receivers :: System -> Chan -> [(ChanReceiver, Task)]
poll_receivers sys chan = error "Tower.AST.System.poll_receivers undefined" -- XXX

event_receivers :: System -> Chan -> [(ChanReceiver, Task)]
event_receivers sys chan = error "Tower.AST.System.event_receivers undefined" -- XXX

{- GARBAGE:
tasks_emitting :: System -> Chan -> [Task]
tasks_emitting sys chan = filter hasemitter ts
  where
  hasemitter t = or (map (\ce -> chanemitter_chan ce == chan)
                      (task_chan_emitters t))
  ts = map snd (D.flatten (system_tasks sys))

tasks_poll_receiving :: System -> Chan -> [Task]
tasks_poll_receiving sys chan = filter hasreceiver ts
  where
  hasreceiver t = or (map (\ce -> chanreceiver_chan ce == chan)
                      (task_chan_poll_receivers t))
  ts = map snd (D.flatten (system_tasks sys))

tasks_event_receiving :: System -> Chan -> [Task]
tasks_event_receiving sys chan = filter hasreceiver ts<commit_msg>towerprime: implement AST.System search functions correctly<commit_after>
module Ivory.Tower.AST.System
  ( System(..)
  , event_emitters
  , poll_receivers
  , event_receivers
  ) where

import Ivory.Tower.AST.Chan
import qualified Ivory.Tower.AST.Directory as D
import Ivory.Tower.AST.Task
import Ivory.Tower.AST.ChanEmitter
import Ivory.Tower.AST.ChanReceiver
import Ivory.Tower.Types.Unique

data System =
  System
    { system_channels :: [Chan]
    , system_tasks    :: D.Dir Unique Task
    } deriving (Eq, Show)

event_emitters :: System -> Chan -> [(ChanEmitter, Task)]
event_emitters sys chan =
    concat (map (\t -> zip (matchingemitters t) (repeat t)) ts)
    where
    matchingemitters t = filter p (task_chan_emitters t)
    p ce = chanemitter_chan ce == chan
    ts = map snd (D.flatten (system_tasks sys))

poll_receivers :: System -> Chan -> [(ChanReceiver, Task)]
poll_receivers sys chan =
    concat (map (\t -> zip (matchingrxers t) (repeat t)) ts)
    where
    matchingrxers t = filter p (task_chan_poll_receivers t)
    p cr = chanreceiver_chan cr == chan
    ts = map snd (D.flatten (system_tasks sys))

event_receivers :: System -> Chan -> [(ChanReceiver, Task)]
event_receivers sys chan =
    concat (map (\t -> zip (matchingrxers t) (repeat t)) ts)
    where
    matchingrxers t = filter p (task_chan_event_receivers t)
    p cr = chanreceiver_chan cr == chan
    ts = map snd (D.flatten (system_tasks sys))

{- GARBAGE:
tasks_emitting :: System -> Chan -> [Task]
tasks_emitting sys chan = filter hasemitter ts
  where
  hasemitter t = or (map (\ce -> chanemitter_chan ce == chan)
                      (task_chan_emitters t))
  ts = map snd (D.flatten (system_tasks sys))

tasks_poll_receiving :: System -> Chan -> [Task]
tasks_poll_receiving sys chan = filter hasreceiver ts
  where
  hasreceiver t = or (map (\ce -> chanreceiver_chan ce == chan)
                      (task_chan_poll_receivers t))
  ts = map snd (D.flatten (system_tasks sys))

tasks_event_receiving :: System -> Chan -> [Task]
tasks_event_receiving sys chan = filter hasreceiver ts
{'fraction_non_alphanumeric': 0.1074676219344172, 'fraction_numerical': 0.0, 'mean_word_length': 3.514925373134328, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3420478', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1176, 'n_words': 345}