# Pastebin P4iBthnt follow [] = [] follow (Knot op os:xs) = head' : tails xs hp where hp = fwd dir op head' = Knot hp (Set.insert hp os) tails = para (\case Nil -> const [] Cons k@(Knot p s) (sns, r) -> \hp' -> if touching hp' p then k : sns else let np = towardsPrev p hp' in Knot np (Set.insert np s) : r np)