applicationOf :: world -> [Rule world] -> IO ()
applicationOf w rules = interactionOf w step event picture
  where
    step dt = foldl' (.) id [f dt | f <- concatMap stepHandlers rules]
    event ev = foldl' (.) id [f ev | f <- concatMap eventHandlers rules]
    picture w = pictures [pic w | pic <- concatMap pictureHandlers rules]
    stepHandlers (TimeRule f) = [f]
    stepHandlers (Rules rs) = concatMap stepHandlers rs
    stepHandlers _ = []
    eventHandlers (EventRule f) = [f 0]
    eventHandlers (Rules rs) = concatMap eventHandlers rs
    eventHandlers _ = []
    pictureHandlers (PictureRule f) = [f 0]
    pictureHandlers (Rules rs) = concatMap pictureHandlers rs
    pictureHandlers _ = []
applicationOf :: world -> [Rule world] -> IO ()
applicationOf w rules = interactionOf w step event picture
  where
    step dt = foldl' (.) id [f dt | f <- concatMap stepHandlers rules]
    event ev = foldl' (.) id [f ev | f <- concatMap eventHandlers rules]
    picture w = pictures [pic w | pic <- concatMap pictureHandlers rules]
    stepHandlers (TimeRule f) = [f]
    stepHandlers (Rules rs) = concatMap stepHandlers rs
    stepHandlers _ = []
    eventHandlers (EventRule f) = [f 0]
    eventHandlers (Rules rs) = concatMap eventHandlers rs
    eventHandlers _ = []
    pictureHandlers (PictureRule f) = [f 0]
    pictureHandlers (Rules rs) = concatMap pictureHandlers rs
    pictureHandlers _ = []
applicationOf w rules = interactionOf w step event picture
  where
    step dt = foldl' (.) id [f dt | f <- concatMap stepHandlers rules]
    event ev = foldl' (.) id [f ev | f <- concatMap eventHandlers rules]
    picture w = pictures [pic w | pic <- concatMap pictureHandlers rules]
    stepHandlers (TimeRule f) = [f]
    stepHandlers (Rules rs) = concatMap stepHandlers rs
    stepHandlers _ = []
    eventHandlers (EventRule f) = [f 0]
    eventHandlers (Rules rs) = concatMap eventHandlers rs
    eventHandlers _ = []
    pictureHandlers (PictureRule f) = [f 0]
    pictureHandlers (Rules rs) = concatMap pictureHandlers rs
    pictureHandlers _ = []