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

Can DataDefinition and InstanceModel implement DefinesQuantity? #3621

Closed
hrzhuang opened this issue Aug 10, 2023 · 1 comment · Fixed by #3627
Closed

Can DataDefinition and InstanceModel implement DefinesQuantity? #3621

hrzhuang opened this issue Aug 10, 2023 · 1 comment · Fixed by #3627
Assignees

Comments

@hrzhuang
Copy link
Collaborator

hrzhuang commented Aug 10, 2023

This is motivated by the definedIn family of functions.

-- | Takes a 'HasSymbol' that is also 'Referable' and outputs as a 'Sentence': "@symbol@ is defined in @reference@."
definedIn :: (Referable r, HasShortName r, HasSymbol r) => r -> Sentence
definedIn q = ch q `S.is` S "defined in" +:+. refS q

-- | Same as 'definedIn', but allows for additional information to be appended to the 'Sentence'.
definedIn' :: (Referable r, HasShortName r, HasSymbol r) => r -> Sentence -> Sentence
definedIn' q info = ch q `S.is` S "defined" `S.in_` refS q +:+. info

Correct me if I'm wrong, but as far as I can see InstanceModel and DataDefinition are the only types that satisfy both Referable and HasSymbol. So those are currently the only possible arguments to the definedIn functions. As part of #3573 and #3617 (part of #3574), I would like to replace HasSymbol with HasOutput in the type signatures of the definedIn functions.

However, HasOutput is in drasil-theory and the definedIn functions are in drasil-lang, and we don't want drasil-lang to depend on drasil-theory (see also #3591 and #3597). Would it be appropriate then to implement DefinesQuantity for InstanceModel and DataDefinition so we can use it in the definedIn functions as follows?

definedIn :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence
definedIn q = ch (q ^. defLhs) `S.is` S "defined in" +:+. refS q

definedIn' :: (Referable r, HasShortName r, DefinesQuantity r) => r -> Sentence -> Sentence
definedIn' q info = ch (q ^. defLhs) `S.is` S "defined" `S.in_` refS q +:+. info
@JacquesCarette
Copy link
Owner

definedIn does not need to be defined in drasil-lang. Things that output Sentence in that way really should be elsewhere.

We don't want to change things based on just where they are being used right now (i.e. that only InstanceModel and DataDefinition currently satisfy the constraints). We want to have the "most meaningful constraints".

Having said that: using DefinesQuantity sounds like a better high-level constraint that the low-level HasSymbol.

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 a pull request may close this issue.

2 participants