Expose function follow to the outside of the module and use Map.lookup instead of (!?) for backward compatibility
This commit is contained in:
parent
675b475a8a
commit
916fde61ae
1 changed files with 4 additions and 3 deletions
|
@ -3,14 +3,15 @@
|
||||||
module Graph (
|
module Graph (
|
||||||
Graph(..)
|
Graph(..)
|
||||||
, editLabel
|
, editLabel
|
||||||
|
, follow
|
||||||
, open
|
, open
|
||||||
, rewind
|
, rewind
|
||||||
, singleton
|
, singleton
|
||||||
, weave
|
, weave
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Data.Map (Map, (!?))
|
import Data.Map (Map)
|
||||||
import qualified Data.Map as Map (delete, empty, insert, toList)
|
import qualified Data.Map as Map (delete, empty, insert, lookup, toList)
|
||||||
import Tree (Tree(..), Structure(..))
|
import Tree (Tree(..), Structure(..))
|
||||||
|
|
||||||
data Vertex edge label = Vertex {
|
data Vertex edge label = Vertex {
|
||||||
|
@ -63,7 +64,7 @@ rewind = open . zipUp
|
||||||
|
|
||||||
follow :: Ord edge => Graph edge label -> edge -> Maybe (Graph edge label)
|
follow :: Ord edge => Graph edge label -> edge -> Maybe (Graph edge label)
|
||||||
follow (Graph {focus, context}) edge =
|
follow (Graph {focus, context}) edge =
|
||||||
edges focus !? edge >>= \vertex -> Just $ Graph {
|
Map.lookup edge (edges focus) >>= \vertex -> Just $ Graph {
|
||||||
focus = vertex
|
focus = vertex
|
||||||
, context = Zipper {
|
, context = Zipper {
|
||||||
origin = context
|
origin = context
|
||||||
|
|
Loading…
Reference in a new issue