From d42c87cd18a5a61ef275730060e6305535355059 Mon Sep 17 00:00:00 2001 From: Erik Post Date: Wed, 5 Feb 2020 13:50:37 +0100 Subject: [PATCH] [#328] [stbx-core] Reduce intermediate data structures. --- stbx-core/src/Statebox/Core/WiringTree.purs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stbx-core/src/Statebox/Core/WiringTree.purs b/stbx-core/src/Statebox/Core/WiringTree.purs index 9edac66b..b8e6c4a8 100644 --- a/stbx-core/src/Statebox/Core/WiringTree.purs +++ b/stbx-core/src/Statebox/Core/WiringTree.purs @@ -43,11 +43,11 @@ linearizeTransitionsAndNames transitions names = sortInitialFinal $ lift3 buildGluedTransition (range 0 (length transitions - 1)) transitions names buildGluedTransition :: TID -> TransitionF' PID -> String -> Glued Transition -buildGluedTransition tId (pre /\ post) name = - case (pre /\ post) of - ([] /\ _ ) -> Initial { name: name, path: [0, 0, 0], transition: tId, tokens: buildTokens pre post } -- the path is [0, 0, 0] because we consider a trivial diagram to be there - (_ /\ [] ) -> Final { name: name, path: [0, 0, 0], transition: tId, tokens: buildTokens pre post } - (inp /\ out) -> Untouched { name: name, path: [0, 0, 0], transition: tId, tokens: buildTokens pre post } +buildGluedTransition tid (pre /\ post) name = + case pre, post of + [], _ -> Initial { name: name, path: [0, 0, 0], transition: tid, tokens: buildTokens pre post } -- the path is [0, 0, 0] because we consider a trivial diagram to be there + _ , [] -> Final { name: name, path: [0, 0, 0], transition: tid, tokens: buildTokens pre post } + _ , _ -> Untouched { name: name, path: [0, 0, 0], transition: tid, tokens: buildTokens pre post } -- | We use this custom function instead of `sortBy` because that does not guarantee -- | the order of equal elements to be preserved.