Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow negative labels #23

Merged
merged 4 commits into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Modelling/StateDiagram/Checkers/Representation.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
import Modelling.StateDiagram.Datatype (
Connection(..),
StateDiagram(..),
UMLStateDiagram(unUML'),
UMLStateDiagram(unUML'), unUML,
)

import Modelling.StateDiagram.Checkers.Helpers (getSubstates, lastSecNotCD)

checkRepresentation :: UMLStateDiagram n Int -> Maybe String
checkRepresentation a
| not (flip unUML a $ \_ substates _ _ -> all checkNegativeLabels substates) =
Just "Negative numbers are not allowed in labels."
| not (checkSubstatesCD $ unUML' a) =

Check warning on line 18 in src/Modelling/StateDiagram/Checkers/Representation.hs

View workflow job for this annotation

GitHub Actions / build_and_test (ubuntu-latest, stack)

In the use of ‘unUML'’
Just "Error: CombineDiagram constructor must contain at least 2 StateDiagram and no other type of constructor"
| not (checkEmptyConnPoint $ unUML' a) =

Check warning on line 20 in src/Modelling/StateDiagram/Checkers/Representation.hs

View workflow job for this annotation

GitHub Actions / build_and_test (ubuntu-latest, stack)

In the use of ‘unUML'’
Just "Error: Neither the pointFrom nor the pointTo of a connection is an empty list"
| not (checkSubC $ unUML' a) =

Check warning on line 22 in src/Modelling/StateDiagram/Checkers/Representation.hs

View workflow job for this annotation

GitHub Actions / build_and_test (ubuntu-latest, stack)

In the use of ‘unUML'’
Just "Error: Connection Points"
| not (checkConnFromToRegion $ unUML' a) =
Just "connections from/to regions themselves"
Expand Down Expand Up @@ -79,3 +81,8 @@
&& all checkStartToRegion substates
checkStartToRegion CombineDiagram { substates } = all checkStartToRegion substates
checkStartToRegion _ = True

checkNegativeLabels :: StateDiagram n Int [Connection Int] -> Bool
checkNegativeLabels StateDiagram{label,substates} = label >= 0 && all checkNegativeLabels substates
checkNegativeLabels CombineDiagram{label,substates} = label >= 0 && all checkNegativeLabels substates
checkNegativeLabels sd = label sd >= 0
Loading