Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5848081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:48:34+00:00 2026-05-22T12:48:34+00:00

I want to do some source code transformation (automatic import list cleanup) and I’d

  • 0

I want to do some source code transformation (automatic import list cleanup) and I’d like to preserve comments and formatting. I heard some stuff on and off about parsers that do this, I think for the ghc parser.

It looks like I might be able to do this with hs-src-exts Language.Haskell.Exts.Annotate and its SrcSpans by pulling things out of the file. I think the SrcsSpanInfo only covers the parsed parts, but I could theoretically figure out the comments by looking at what’s in between. But it’s not documented in much detail, and there are no helper functions I can find, and it looks like a hassle, e.g. there’s no easy way to print out a parsed expression including formatting and comments. So I think it’s not meant to be used in this way, it’s just so you can highlight code in the file or something. My impression is that the author meant to use annotations to support this, but never got around to it.

It looks like neither yi nor leksah do this. I feel like HaRe might, but it’s not super documented. Is there a haskell parser out there that does this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T12:48:35+00:00Added an answer on May 22, 2026 at 12:48 pm

    The haskell-src-exts recently got support for preserving comments, and it already records src spans. I’m not sure if pretty printing is supported, but you could probably get that working.

    The GHC parser also does similar things.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some source code file which has mixed tabs/spaces and I want to
As the title says, I want to parse some Java source code in Java.
How can I create a jar from some Scala source code? I want to
I want some slightly 'dynamic' XML source files. I want some of the element
I have coordinates from some source and want to tag my jpg files with
I want some particular urls like springer.com to automatically convert to springer.com.proxy1.mycollege.edu. The second
I have been browsing some php source code and need to know how the
I want to do some analysis on some old code and need to be
According to google and some other sources (e.g., http://www.enterprisedt.com/publications/oracle/result_set.html ), if I want to
I want some of the items to be bold depending on a property of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.