From 916fde61ae8c1effbf093ae73a1b5d215a3ba37b Mon Sep 17 00:00:00 2001 From: Tissevert Date: Mon, 6 May 2019 16:47:29 +0200 Subject: [PATCH] Expose function follow to the outside of the module and use Map.lookup instead of (!?) for backward compatibility --- src/Graph.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Graph.hs b/src/Graph.hs index 88f9a67..313530d 100644 --- a/src/Graph.hs +++ b/src/Graph.hs @@ -3,14 +3,15 @@ module Graph ( Graph(..) , editLabel + , follow , open , rewind , singleton , weave ) where -import Data.Map (Map, (!?)) -import qualified Data.Map as Map (delete, empty, insert, toList) +import Data.Map (Map) +import qualified Data.Map as Map (delete, empty, insert, lookup, toList) import Tree (Tree(..), Structure(..)) data Vertex edge label = Vertex { @@ -63,7 +64,7 @@ rewind = open . zipUp follow :: Ord edge => Graph edge label -> edge -> Maybe (Graph edge label) follow (Graph {focus, context}) edge = - edges focus !? edge >>= \vertex -> Just $ Graph { + Map.lookup edge (edges focus) >>= \vertex -> Just $ Graph { focus = vertex , context = Zipper { origin = context