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

feat(#331): Literate Haskell Support #344

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

grantlemons
Copy link
Collaborator

@grantlemons grantlemons commented Dec 31, 2024

The parser does not support parsing the actual code beyond extracting identifiers, but I don't know how that would be implemented considering the vastly different contexts.
If we were able to, using CommentParser would be great. It is a little weird to have comments in your code when it's literate programming anyway, but I can see it happening.

Will need to be revisited before/after merging #302 because of the changes to the Parser and Masker traits.

Copy link
Collaborator

@elijah-potter elijah-potter left a comment

Choose a reason for hiding this comment

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

Looks and seems to work great! Mostly just looking for enhanced documentation. Why did you make the decisions you did?

@@ -0,0 +1,11 @@
[package]
name = "harper-literate-haskell"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Make sure this includes all the keys that the other public crates include (repository, etc).

}

impl Masker for LiterateHaskellMasker {
fn create_mask(&mut self, source: &[char]) -> harper_core::Mask {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a language specification you're referencing for this implementation? If so, make sure to link it here.

@@ -0,0 +1,145 @@
use harper_core::{CharStringExt, Mask, Masker, Span};

pub struct LiterateHaskellMasker {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Give us a brief description of what this does. What part of the text are we masking?

Keep in mind that this will get posted on crates.io and therefore docs.rs, so we want doc-comments that somewhat explain things.

let source = text.chars().collect_vec();
let parser = LiterateHaskellParser;

if let Some(new_dict) = parser.create_ident_dict(&source) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could this be generalized to the other languages?

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