Skip to content

Draft implementation of SystemKind.#4274

Merged
JacquesCarette merged 8 commits intomainfrom
systemKinds
Jul 21, 2025
Merged

Draft implementation of SystemKind.#4274
JacquesCarette merged 8 commits intomainfrom
systemKinds

Conversation

@balacij
Copy link
Collaborator

@balacij balacij commented Jul 10, 2025

Contributes to #3260

EDIT:

This PR is now ready for review.

ORIGINAL PR DESCRIPTION:

Creating this PR as a draft because:

  1. It's a draft implementation.
  2. The CI will fail because I didn't propagate all System-related changes across all case studies -- only SSP.
  3. I would like some feedback before I proceed with continuing the implementation.

Copy link
Collaborator Author

@balacij balacij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are only two use sites for kind at the moment -- the same two as it were before this PR.

For the case studies, kind is used in exactly one spot: titles. Testing by changing SSP's kind to nw progName:

diff --strip-trailing-cr -r -X ../.gitignore --exclude=*.prof --exclude=.drasil stable/ssp/SRS/HTML/SSP_SRS.html build/ssp/SRS/HTML/SSP_SRS.html
6c6
<       Software Requirements Specification for Slope Stability analysis Program
---
>       Slope Stability analysis Program for Slope Stability analysis Program
27c27
... (snip)
< \title{Software Requirements Specification for Slope Stability analysis Program}
---
> \title{Slope Stability analysis Program for Slope Stability analysis Program}
diff --strip-trailing-cr -r -X ../.gitignore --exclude=*.prof --exclude=.drasil stable/ssp/SRS/mdBook/book.toml build/ssp/SRS/mdBook/book.toml
5c5
< title = "Software Requirements Specification for Slope Stability analysis Program"
---
> title = "Slope Stability analysis Program for Slope Stability analysis Program"
... (snip)

For the notebook, the same kind of use: titles. Testing by changing Projectile's "Notebook" lesson plan to nw projectileMotion:

diff --strip-trailing-cr -r -X ../.gitignore --exclude=*.prof --exclude=.drasil stable/projectile/Lesson/Projectile_Lesson.ipynb build/projectile/Lesson/Projectile_Lesson.ipynb
8c8
<     "# Notebook for Projectile Motion Lesson\n",
---
>     "# Projectile Motion Lesson for Projectile Motion Lesson\n",

For the website, neither of these use sites are used. The title appearing in your web browsers are declared using the first field of Document (as in mkDoc).

Comment on lines 37 to 40
data SystemKind =
SRS
| Notebook
| Website
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 kinds; 1 for each of our types of categories of Systems created.

The ICO-related bits will go into the SRS constructor, and the SRS constructor will need to take on at least a bit more information: problem information (the ICO problem information) and solution (the theories, data definitions, constants, etc.).

I'm not sure what the other two will contain, but the goal will be to at least not have to instantiate a bunch of unused unused components of a System in the "notebook":

si :: System
si = SI {
_sys = projectileMotion,
_kind = Doc.notebook,
_authors = [spencerSmith],
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_quants = [] :: [QuantityDict],
_instModels = [],
_datadefs = [],
_configFiles = [],
_inputs = [] :: [QuantityDict],
_outputs = [] :: [QuantityDict],
_constraints = [] :: [ConstrainedChunk],
_constants = [] :: [ConstQDef],
_systemdb = symbMap,
_usedinfodb = usedDB
}

And the website:

-- | System information.
si :: FolderLocation -> System
si fl = SI {
_sys = webName,
_kind = web,
_authors = [] :: [Person],
_quants = [] :: [QuantityDict],
_purpose = [],
_background = [],
_motivation = [],
_scope = [],
_instModels = [],
_datadefs = [],
_configFiles = [],
_inputs = [] :: [QuantityDict],
_outputs = [] :: [QuantityDict],
_constraints = [] :: [ConstrainedChunk],
_constants = [] :: [ConstQDef],
_systemdb = symbMap fl,
_usedinfodb = usedDB
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm following the discussion in #3260 to create SystemKind, but an alternative implementation might avoid the sum type:

data System sk where
  SI :: Concept sk => ...
    _kind :: sk,
...
  } -> System sk

How do we decide which is the better implementation? I'm not immediately sure, but #4271 (comment) is relevant ++ do we want SystemKind to be an open sum type? If so, this is the better implementation -- and we can also do some work to ensure that data placed in the hole have some sort of kindOf field set to "system kind."

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having System be a data-structure that carries a payload is probably a good idea. It should likely be structured in such a way that the first piece of data is common to all kinds (as a bundle of data).

-- | Project Example motivation.
type Motivation = [Sentence]

data SystemKind =
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking you should replace SRS by 2 things: RunnableSoftware and Specification.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split in b78bd29 -- Still a very simple implementation, I imagine we'll take multiple passes at moving things around. Also, I'm not using RunnableSoftware at all yet. Should it be used for the examples that currently support software generation? Or were you thinking that System could also replace CodeSpec?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My memory is that CodeSpec serves a different purpose. Yes, RunnableSoftware should be used for those examples.

Comment on lines 37 to 40
data SystemKind =
SRS
| Notebook
| Website
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having System be a data-structure that carries a payload is probably a good idea. It should likely be structured in such a way that the first piece of data is common to all kinds (as a bundle of data).

HasUID j, Constrained j) =>
{ _sys :: a
, _kind :: b
, _kind :: SystemKind
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does feel like an improvement! It adds more information into _kind.

Copy link
Collaborator Author

@balacij balacij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite a few subsequent PRs are needed! But that's good.

- drasil-lang
- drasil-metadata
- drasil-printers
- drasil-system
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm somewhat surprised that I need to add this to the other case studies. Things from drasil-system are being re-exported somewhere they shouldn't be.

@balacij balacij marked this pull request as ready for review July 18, 2025 21:40
@JacquesCarette JacquesCarette merged commit e317365 into main Jul 21, 2025
5 checks passed
@JacquesCarette JacquesCarette deleted the systemKinds branch July 21, 2025 20:26
@balacij balacij mentioned this pull request Jul 23, 2025
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants