Skip to content

Commit

Permalink
fix: foldr messages order
Browse files Browse the repository at this point in the history
  • Loading branch information
linsyking committed May 9, 2023
1 parent 24016e6 commit 7b81456
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "linsyking/messenger-core",
"summary": "Core library for Messenger.",
"license": "BSD-3-Clause",
"version": "3.0.1",
"version": "3.0.2",
"exposed-modules": {
"Definitions": [
"Messenger.Recursion",
Expand Down
12 changes: 6 additions & 6 deletions src/Messenger/RecursionArray.elm
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ updateOnce rec env msg objs =
Array.foldr
(\ele ( lastObjs, ( lastMsgUnfinished, lastMsgFinished ), lastEnv ) ->
let
( newObjs, newMsg, newEnv ) =
( newObj, newMsg, newEnv ) =
rec.update ele lastEnv msg

finishedMsg =
Expand All @@ -53,7 +53,7 @@ updateOnce rec env msg objs =
unfinishedMsg =
List.filter (\( x, _ ) -> not (rec.super x)) newMsg
in
( insertAt 0 newObjs lastObjs, ( unfinishedMsg ++ lastMsgUnfinished, finishedMsg ++ lastMsgFinished ), newEnv )
( insertAt 0 newObj lastObjs, ( lastMsgUnfinished ++ unfinishedMsg, lastMsgFinished ++ finishedMsg ), newEnv )
)
( Array.empty, ( [], [] ), env )
objs
Expand Down Expand Up @@ -96,7 +96,7 @@ updateRemain rec env ( unfinishedMsg, finishedMsg ) objs =
let
-- Update the object with all messages in msgMatched
( newObj, ( newMsgUnfinished, newMsgFinished ), newEnv2 ) =
List.foldr
List.foldl
(\msg ( lastObj2, ( lastMsgUnfinished2, lastMsgFinished2 ), lastEnv2 ) ->
let
( newEle, newMsgs, newEnv3 ) =
Expand All @@ -116,14 +116,14 @@ updateRemain rec env ( unfinishedMsg, finishedMsg ) objs =
unfinishedMsgs =
List.filter (\( x, _ ) -> not (rec.super x)) newMsgs
in
( newEle, ( unfinishedMsgs ++ lastMsgUnfinished2, finishedMsgs ++ lastMsgFinished2 ), newEnv3 )
( newEle, ( lastMsgUnfinished2 ++ unfinishedMsgs, lastMsgFinished2 ++ finishedMsgs ), newEnv3 )
)
( ele, ( [], [] ), env )
msgMatched
in
( insertAt 0 newObj lastObjs, ( newMsgUnfinished ++ lastMsgUnfinished, newMsgFinished ++ lastMsgFinished ), newEnv2 )
( insertAt 0 newObj lastObjs, ( lastMsgUnfinished ++ newMsgUnfinished, lastMsgFinished ++ newMsgFinished ), newEnv2 )
)
( Array.empty, ( [], [] ), env )
objs
in
updateRemain rec newEnv ( newUnfinishedMsg, newFinishedMsg ++ finishedMsg ) newObjs
updateRemain rec newEnv ( newUnfinishedMsg, finishedMsg ++ newFinishedMsg ) newObjs
10 changes: 5 additions & 5 deletions src/Messenger/RecursionList.elm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ updateOnce rec env msg objs =
unfinishedMsg =
List.filter (\( x, _ ) -> not (rec.super x)) newMsg
in
( newObj :: lastObjs, ( unfinishedMsg ++ lastMsgUnfinished, finishedMsg ++ lastMsgFinished ), newEnv )
( newObj :: lastObjs, ( lastMsgUnfinished ++ unfinishedMsg, lastMsgFinished ++ finishedMsg ), newEnv )
)
( [], ( [], [] ), env )
objs
Expand Down Expand Up @@ -94,7 +94,7 @@ updateRemain rec env ( unfinishedMsg, finishedMsg ) objs =
let
-- Update the object with all messages in msgMatched
( newObj, ( newMsgUnfinished, newMsgFinished ), newEnv2 ) =
List.foldr
List.foldl
(\msg ( lastObj2, ( lastMsgUnfinished2, lastMsgFinished2 ), lastEnv2 ) ->
let
( newEle, newMsgs, newEnv3 ) =
Expand All @@ -114,14 +114,14 @@ updateRemain rec env ( unfinishedMsg, finishedMsg ) objs =
unfinishedMsgs =
List.filter (\( x, _ ) -> not (rec.super x)) newMsgs
in
( newEle, ( unfinishedMsgs ++ lastMsgUnfinished2, finishedMsgs ++ lastMsgFinished2 ), newEnv3 )
( newEle, ( lastMsgUnfinished2 ++ unfinishedMsgs, lastMsgFinished2 ++ finishedMsgs ), newEnv3 )
)
( ele, ( [], [] ), env )
msgMatched
in
( newObj :: lastObjs, ( newMsgUnfinished ++ lastMsgUnfinished, newMsgFinished ++ lastMsgFinished ), newEnv2 )
( newObj :: lastObjs, ( lastMsgUnfinished ++ newMsgUnfinished, lastMsgFinished ++ newMsgFinished ), newEnv2 )
)
( [], ( [], [] ), env )
objs
in
updateRemain rec newEnv ( newUnfinishedMsg, newFinishedMsg ++ finishedMsg ) newObjs
updateRemain rec newEnv ( newUnfinishedMsg, finishedMsg ++ newFinishedMsg ) newObjs

0 comments on commit 7b81456

Please sign in to comment.