diff options
| author | Lars-Dominik Braun <lars@6xq.net> | 2024-08-17 07:44:14 +0200 |
|---|---|---|
| committer | Lars-Dominik Braun <lars@6xq.net> | 2024-08-17 07:47:16 +0200 |
| commit | 79aaf53023cd71c3eabdf63c7dd88523902fe0e4 (patch) | |
| tree | 760781cc02a68f8ada387e4de8294a2c693c4c55 /src/lib/Codec/Pesto/Graph.lhs | |
| parent | cc2aaa6e46dfac12dfad39414925d5a535a91d19 (diff) | |
| download | pesto-79aaf53023cd71c3eabdf63c7dd88523902fe0e4.tar.gz pesto-79aaf53023cd71c3eabdf63c7dd88523902fe0e4.tar.bz2 pesto-79aaf53023cd71c3eabdf63c7dd88523902fe0e4.zip | |
Fix non-exhaustive pattern warnings with GHC 9.2.
Diffstat (limited to 'src/lib/Codec/Pesto/Graph.lhs')
| -rw-r--r-- | src/lib/Codec/Pesto/Graph.lhs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/Codec/Pesto/Graph.lhs b/src/lib/Codec/Pesto/Graph.lhs index 5628ec3..b959d59 100644 --- a/src/lib/Codec/Pesto/Graph.lhs +++ b/src/lib/Codec/Pesto/Graph.lhs @@ -28,6 +28,7 @@ Language semantics > import Data.List (sort, nub, sortOn) > import Test.HUnit hiding (test, Node) > import Data.Ratio ((%), Ratio) +> import Data.Either (fromRight) > > import Codec.Pesto.Parse hiding (test) @@ -158,7 +159,9 @@ These are helper functions: > consumeStack (_, s, edges) i = > let > stack = dropWhile null s -> (top:sx) = if null stack then [[]] else stack +> alwaysStack = if null stack then [[]] else stack +> top = head alwaysStack +> sx = tail alwaysStack > in (Just i, []:top:sx, edgesTo i top ++ edges) > edgesTo i = map (\x -> (x, i)) @@ -342,8 +345,8 @@ Appendix > runGraphWith f doc expect = sort edges ~?= sort expect > where -> (Right op) = (head . extract . snd . unzip) <$> parse ("%pesto " ++ doc) -> nodes = zip [firstNodeId..] op +> op = (head . extract . snd . unzip) <$> parse ("%pesto " ++ doc) +> nodes = zip [firstNodeId..] (fromRight (error "unreachable") op) > edges = f nodes > cmpGraph = runGraphWith toGraph > cmpGraphRef = runGraphWith resolveReferences @@ -363,6 +366,8 @@ Find graph’s root node(s), that is a node without outgoing edges: Get all nodes with edges pointing towards nodeid > incomingEdges edges nodeid = filter ((==) nodeid . snd) edges + +> incomingNodes :: Nodes a -> Edges -> NodeId -> Nodes a > incomingNodes nodes edges nodeid = map ((!!) nodes . fst) $ incomingEdges edges nodeid > outgoingEdges edges nodeid = filter ((==) nodeid . fst) edges |
