Skip to content

Add diagram for Concept* chunks + related typeclasses and ShortName with namespace refactoring #4031

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

balacij
Copy link
Collaborator

@balacij balacij commented Mar 26, 2025

Contributes to #4032

Builds on #4030

@balacij balacij requested a review from smiths March 26, 2025 19:24
@balacij
Copy link
Collaborator Author

balacij commented Mar 26, 2025

I'm going to create a proper issue and edit this description + that for #4030.

Edit: Done. #4032.

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.

Where/how should we discus the design? Should we wait until we have it all? Maybe have a DESIGN TALKING POINTS.md file in the meanwhile?

Comment on lines +134 to +136
-- | For projecting out to the 'ConceptChunk' data-type.
cw :: Concept c => c -> ConceptChunk
cw c = ConDict (nw c) (c ^. defn) (cdom c)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should 'forgetting' other structural knowledge ever be necessary/desired?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If not, I will track constructors too. Actually, I might just do that regardless.

Copy link
Owner

Choose a reason for hiding this comment

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

Forgetting knowledge was forced on us when creating lists because Haskell wanted a uniform type. If we use lenses (getters, really) uniformly all over, then I'm pretty sure we won't need these at all anymore.

dcc :: String -> NP -> String -> ConceptChunk
-- | Smart constructor for creating concept chunks given a 'UID', 'NounPhrase'
-- ('NP') and definition (as a 'String').
dcc i ter des = ConDict (mkIdea i ter Nothing) (S des) []
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Nesting a mkIdea looks odd to me. A chunk is being constructed purely within it. This PR is already making me think that:

  1. An IdeaDict shouldn't be a chunk at all. There should be a term cache somewhere/somehow, but it should only be used to track which domains define which terms and how.
  2. A ConceptChunk perhaps shouldn't be a chunk either, but a kind of "Chunk Core" for all other chunks.

A ConceptChunk could act like a "fundamental chunk components" packet/core that all other chunks contain for the sake of having a UID, NP (a 'term', or a reference to the hypothetical alternative to an IdeaDict), Sentence (description). Ironically, all chunks would "inherit" these pieces of information from the packet/core.

Copy link
Owner

Choose a reason for hiding this comment

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

While you're not wrong, you're currently looking at this from too much of an implementation-oriented POV.

A Chunk is just a unique piece of knowledge. Some of our IdeaDict really are "all" of the knowledge we know about certain items.

Now, you are correct that this call to mkIdea inside ConDict is extremely suspicious. But I think this is an 'en'coding bug. We need to better understand what it is we're trying to 'encode' with dcc, and that will inform our design.

-- | Defines a chunk.
class Definition c where
-- | Provides (a 'Lens' to) the definition for a chunk.
defn :: Lens' c Sentence
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's be silly. An idea: Why not parameterize the Sentence? We would then be able to define meaning to different contexts:

class Definition chunk domain where
  defn :: chunk -> domain -- or Lens' chunk domain

Then, we could have something like:

instance Definition QuantityDict Sentence where defn = ...
instance Definition QuantityDict Equational where defn = ...
instance Definition QuantityDict Implementation where defn = ...

Equational and Implementation names are obtained from Drasil's Stage data type that a QuantityDict's Symbol depends on. They're the constructors of the Stage type.

It looks familiar now, but the code is still gibberish. What is Equational and Implementation now? I'm not sure!

Copy link
Owner

Choose a reason for hiding this comment

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

This 'silly' suggestion is the germ of a good one. What constitutes a Definition is overloaded.

We also need to differentiate between "X has definition Y (in terms of Z)" and "X contains a definition". I think we need to analyze some examples to figure out what we need to be able to say in practice.

(Your exact suggestion seems to mix things, and probably Drasil does too, so all of that needs de-tangled).

@smiths
Copy link
Collaborator

smiths commented Mar 27, 2025

Where/how should we discuss the design? Should we wait until we have it all? Maybe have a DESIGN TALKING POINTS.md file in the meanwhile?

I don't know when, but at some point we should have an in-person design discussion—recording thoughts in a talking points file sound like a good prep for the meeting. The other thing I hope for before the meeting is examples of the different types of information. I'm not as familiar with the code as you are, so I don't remember the difference between an idea and a concept, etc. 😄

@balacij
Copy link
Collaborator Author

balacij commented Mar 27, 2025

That's a good idea. Optimally, the diagram + discussion should be enough to explain how information is organized (concretely) and used (at least abstractly) in Drasil. I suppose that documenting how/where chunks find use across the packages will be helpful then. I'll add that to this PR + the previous.

@JacquesCarette
Copy link
Owner

I think building on #4030 is a bad idea. There are conceptually separate things going on here, some of which are good idea, some of which are not. So right now, because of the bad ones, the whole PR ends up having to be rejected.

Please stick to making small PRs! And try to keep them separate, conceptually.

Copy link
Owner

@JacquesCarette JacquesCarette left a comment

Choose a reason for hiding this comment

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

I'm afraid you're prematurely doing code changes.

sDom [d] = d
sDom d = error $ "Expected ConceptDomain to have a single domain, found " ++
show (length d) ++ " instead."

-- TODO: conceptual typeclass?
-- TODO: I was thinking of splitting QDefinitions into Definitions with 2 type variables
Copy link
Owner

Choose a reason for hiding this comment

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

QDefinition, while an awful name, was still better: a QDefinition grabbed the definition of a quantity. That quantities must have a definition makes sense. Definition on its own, not so much.

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.

3 participants