Skip to content

Dot composition detection #591

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

Merged
merged 2 commits into from
Apr 23, 2015
Merged

Dot composition detection #591

merged 2 commits into from
Apr 23, 2015

Conversation

hmgibson23
Copy link
Contributor

As per #589

Seems to work pretty well but I'm welcome to alternatives!

I removed the forall check since it seems redundant now.

@hmgibson23
Copy link
Contributor Author

Ah okay. Sure will try those.

@hmgibson23
Copy link
Contributor Author

@gracjan not sure I understand the issue with the lonely . since it will return nil - isn't that expected?

@gracjan
Copy link
Contributor

gracjan commented Apr 22, 2015 via email

@hmgibson23
Copy link
Contributor Author

It doesn't crash for me. What version of Emacs are you using?

@gracjan
Copy link
Contributor

gracjan commented Apr 22, 2015 via email

@hmgibson23
Copy link
Contributor Author

Okay well it seems to work fine. I've put back the forall code and all seems to work well.

@gracjan
Copy link
Contributor

gracjan commented Apr 22, 2015 via email

@deviant-logic
Copy link
Contributor

Tried it. It's better than the current state of things, so if I have a vote, I vote merge it (or to be more consistent merge a change that looks like:

(defun haskell-font-lock-dot-is-not-composition (start)
  "Return non-nil if the \".\" at START is not a composition operator.
This is the case if the \".\" is part of a \"forall <tvar> . <type>\"."
  (save-excursion
    (goto-char start)
    (or (re-search-backward "\\<forall\\>[^.\"]*\\="
                            (line-beginning-position) t)
        (not (or (eq ?\  (char-before start))
                 (eq ?\  (char-after  start)))))))

Which uses eq and ?\ instead of turning (char-before start) into a string to compare it to " ". I don't know if that actually matters, but it's how the rest of the file seems to go about things.

This change still misses the case where (.) is used as composition without spaces around it, which is common in lens-style code like _1._2._3. For that matter, it also misses (.). I conjecture that the rule we're looking for is closer to: "if the character before start is is a word character, and the identifier before start starts with a capital letter, and we're not dealing with the forall case, then dot isn't composition"?

@gracjan
Copy link
Contributor

gracjan commented Apr 23, 2015

What you really want is:

(?:MODID\.)*([allsymbolchars]+)

and then use prettyfication only when (match-string 1) is exactly equal to a single dot.

Current prettyfication engine is not ready for such logic.

@gracjan
Copy link
Contributor

gracjan commented Apr 23, 2015

@deviant-logic: You solutions is slightly better but it is still a hack. I'll merge the version by @hmgibson23 because it is good enough for the time being.

Meanwhile we wait for a skilled volunteer to actually fix the whole mess.

gracjan added a commit that referenced this pull request Apr 23, 2015
Dot composition detection in hierarchical modules
@gracjan gracjan merged commit 7270be9 into haskell:master Apr 23, 2015
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