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

Use Writer monad instead of State to annotate comments #47

Merged
merged 1 commit into from
Nov 9, 2024

Conversation

msakai
Copy link
Collaborator

@msakai msakai commented Nov 9, 2024

resolves #22

@msakai msakai force-pushed the feature/comment-as-writer branch from 6ca7ad6 to 3709417 Compare November 9, 2024 05:36
Comment on lines -508 to +509
instance Commented (State [String]) where
withComments (F mf) s = F $ do { f <- mf; put s; return f }
instance Commented (Writer [String]) where
withComments (F mf) s = F $ do { f <- mf; tell s; return f }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The behavior appears to change from “replace” to “append,” but in reality, there is no difference.

The only place withComments is used is

logic-TPTP/ParserC.y

Lines 148 to 150 in b02af74

quantified_formula :: {FormulaC}
quantified_formula : quantifier lbra variable_list rbra colon unitary_formula
{ $1 $3 $6 `withComments` comm $5 }

and the quantifier is defined as

logic-TPTP/ParserC.y

Lines 188 to 189 in b02af74

quantifier :: {[V] -> FormulaC -> FormulaC}
quantifier : exclam { for_all } | question { exists }

and for_all / exists are defined as:

-- | Universal quantification
for_all :: Pointed c => [V] -> (F c) -> F c
for_all vars x = (F . point) $ Quant All vars x
-- | Existential quantification
exists :: Pointed c => [V] -> (F c) -> F c
exists vars x = (F . point) $ Quant Exists vars x

Therefore, mf in the above code is always point of something, i.e. the annotation is empty.

@msakai msakai merged commit fa0e5ac into DanielSchuessler:master Nov 9, 2024
8 checks passed
@msakai msakai deleted the feature/comment-as-writer branch November 9, 2024 06:13
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.

Writer monad instead of State monad to annotate formula with comments
1 participant