Skip to content

Commit 303c647

Browse files
Merge branch 'develop-clean-copilot-diagrams' into develop. Close #351.
**Description** The diagrams template includes two functions, `noneOf` and `checkValidTransitions`, that are not used by the backend or any of the generated code. While in general they can be useful, since they are currently not being used, it's best to remove them. **Type** - Bug: Template includes unused code. **Additional context** None. **Requester** - Ivan Perez. **Method to check presence of bug** The template file `ogma-core/templates/diagram/Copilot.hs` contains the functions `noneOf` and `checkValidTransitions`, which are not used anywhere in the template, and are not mentioned anywhere in the diagrams backend `ogma-core/src/Command/Diagram.hs`. Because that module uses a function `noneOf` from `Text.Megaparsec`, it's not possible to use regexp matching to determine that the functions in the template are also not used by text inserted in the module by the backend. **Expected result** The template file `ogma-core/templates/diagram/Copilot.hs` does not include the functions `noneOf` or `checkValidTransitions`. **Solution implemented** Remove the definitions `noneOf` and `checkValidTransitions` from `ogma-core/templates/diagram/Copilot.hs`. Remove any references to the aforementioned functions from any existing documentation. **Further notes** None.
2 parents 3a15256 + c2a97fa commit 303c647

File tree

3 files changed

+14
-42
lines changed

3 files changed

+14
-42
lines changed

ogma-core/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Revision history for ogma-core
22

3+
## [1.X.Y] - 2026-01-25
4+
5+
* Remove unused functions from diagram template (#351).
6+
37
## [1.12.0] - 2026-01-21
48

59
* Version bump 1.12.0 (#336).

ogma-core/src/Command/Diagram.hs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,11 @@ import Language.Trans.SMV2Copilot as SMV (boolSpec2Copilot,
9191
--
9292
-- PRE: The file given is readable, contains a valid file with recognizable
9393
-- format, the formulas in the file do not use any identifiers that exist in
94-
-- Copilot, or any of @stateMachine@, @externalState@, @noneOf@,
95-
-- @checkValidTransitions@, @main@, @spec@, @stateMachine1@, @clock@, @ftp@,
96-
-- @notPreviousNot@. All identifiers used are valid C99 identifiers. The
97-
-- template, if provided, exists and uses the variables needed by the diagram
98-
-- application generator. The target directory is writable and there's enough
99-
-- disk space to copy the files over.
94+
-- Copilot, or any of @stateMachine@, @externalState@, @main@, @spec@,
95+
-- @stateMachine1@, @clock@, @ftp@, @notPreviousNot@. All identifiers used are
96+
-- valid C99 identifiers. The template, if provided, exists and uses the
97+
-- variables needed by the diagram application generator. The target directory
98+
-- is writable and there's enough disk space to copy the files over.
10099
diagram :: FilePath -- ^ Path to a file containing a diagram
101100
-> DiagramOptions -- ^ Customization options
102101
-> IO (Result ErrorCode)
@@ -138,12 +137,11 @@ diagram fp options = do
138137
--
139138
-- PRE: The file given is readable, contains a valid file with recognizable
140139
-- format, the formulas in the file do not use any identifiers that exist in
141-
-- Copilot, or any of @stateMachine@, @externalState@, @noneOf@,
142-
-- @checkValidTransitions@, @main@, @spec@, @stateMachine1@, @clock@, @ftp@,
143-
-- @notPreviousNot@. All identifiers used are valid C99 identifiers. The
144-
-- template, if provided, exists and uses the variables needed by the diagram
145-
-- application generator. The target directory is writable and there's enough
146-
-- disk space to copy the files over.
140+
-- Copilot, or any of @stateMachine@, @externalState@, @main@, @spec@,
141+
-- @stateMachine1@, @clock@, @ftp@, @notPreviousNot@. All identifiers used are
142+
-- valid C99 identifiers. The template, if provided, exists and uses the
143+
-- variables needed by the diagram application generator. The target directory
144+
-- is writable and there's enough disk space to copy the files over.
147145
diagram' :: FilePath
148146
-> DiagramOptions
149147
-> ExprPair

ogma-core/templates/diagram/Copilot.hs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,33 +46,3 @@ stateMachineGF (initialState, finalState, noInputData, transitions, badState) =
4646

4747
ifThenElses ((s1,i,s2):ss) =
4848
ifThenElse (previousState == constant s1 && i) (constant s2) (ifThenElses ss)
49-
50-
-- | True when the given input stream does hold any of the values in the given
51-
-- list.
52-
noneOf :: [Stream Bool] -> Stream Bool
53-
noneOf [] = true
54-
noneOf (x:xs) = not x && noneOf xs
55-
56-
-- | Given a list of transitions, and a current state, and a list of possible
57-
-- destination states, produce a list of booleans indicating if a transition to
58-
-- each of the destination states would be valid.
59-
checkValidTransitions :: [(Word8, Stream Bool, Word8)]
60-
-> Stream Word8
61-
-> [Word8]
62-
-> [Stream Bool]
63-
checkValidTransitions transitions curState destinations =
64-
map (checkValidTransition transitions curState) destinations
65-
66-
-- | Given a list of transitions, and a current state, and destination states,
67-
-- produce a list of booleans indicating if a transition to each of the
68-
-- destination states would be valid.
69-
checkValidTransition :: [(Word8, Stream Bool, Word8)]
70-
-> Stream Word8
71-
-> Word8
72-
-> Stream Bool
73-
checkValidTransition [] _ _ = true
74-
checkValidTransition ((so1, c, sd1):sx) so2 sd2 =
75-
ifThenElse
76-
((constant so1 == so2) && (constant sd1 == constant sd2))
77-
c
78-
(checkValidTransition sx so2 sd2)

0 commit comments

Comments
 (0)