# Pastebin j6tRqunb follow :: Dir -> [Knot] -> [Knot] follow dir = para (\case Nil -> [] Cons (Knot hp hs) (_, []) -> let np = fwd dir hp in [Knot np (Set.insert np hs)] Cons ex@(Knot p s) (_, done@(Knot hp _:_)) | touching hp p -> ex:done | otherwise -> let np = towardsHead p hp in Knot np (Set.insert np s) : done)