From f44bf6259e4b8de1e3a41a24d2d6663a6733c24a Mon Sep 17 00:00:00 2001 From: Tissevert Date: Mon, 13 May 2019 18:27:49 +0200 Subject: [PATCH] Clarify a mapping over a Maybe for clearer syntax --- src/Graph.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Graph.hs b/src/Graph.hs index 09a2f7d..891ce4d 100644 --- a/src/Graph.hs +++ b/src/Graph.hs @@ -63,9 +63,9 @@ rewind graph = graph {focus = root graph} follow :: Ord edge => Graph edge label -> edge -> Maybe (Graph edge label) follow graph@(Graph {vertices, focus}) edge = - Map.lookup edge (edges $ vertices ! focus) >>= \vertexID -> Just $ graph { - focus = vertexID - } + setFocus <$> Map.lookup edge (edges $ vertices ! focus) + where + setFocus vertexID = graph {focus = vertexID} stitch :: (Monoid label, Ord edge) => Graph edge label -> edge -> Graph edge label stitch graph edge =