Expose function follow to the outside of the module and use Map.lookup instead of (!?) for backward compatibility

This commit is contained in:
Tissevert 2019-05-06 16:47:29 +02:00
parent 675b475a8a
commit 916fde61ae
1 changed files with 4 additions and 3 deletions

View File

@ -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