@@ -103,7 +103,15 @@ down = firstChild
103103
104104-- | Move the cursor to the last child of the current `Node`.
105105lastChild :: forall a. Loc a -> Maybe (Loc a)
106−lastChild p@(Loc r) = last <$> down p
106+lastChild n =
107+ case reverse (children n) of
108+ Nil -> Nothing
109+ c:cs ->
110+ Just $ Loc { node: c
111+ , before: cs
112+ , after: Nil
113+ , parents: n : (parents n)
114+ }
107115
108116-- | Move the cursor to a specific sibling by it's index.
109117siblingAt :: forall a. Int -> Loc a -> Maybe (Loc a)