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

Detect {-# LANGUAGE UnboxedTuples #-} automatically #866

Closed
2 tasks done
jmcarthur opened this issue Apr 5, 2024 · 3 comments · Fixed by #868
Closed
2 tasks done

Detect {-# LANGUAGE UnboxedTuples #-} automatically #866

jmcarthur opened this issue Apr 5, 2024 · 3 comments · Fixed by #868

Comments

@jmcarthur
Copy link
Contributor

Completed checklist

  • I've checked the issue tracker for similar issues.
  • I am not creating an issue about adding more configuration options for the styling/layout of hindent, because hindent is not about customizing style.

Problem description

In #419, it is explained that UnboxedTuples is intentionally unsupported by default because it would be mutually exclusive with handling lens operators. Makes sense, but it would be nice if this behavior would be altered by LANGUAGE pragmas so that it doesn't have to be overridden in the command manually.

Proposed solution

If the file contains the UnboxedTuples language extension, behave as though passing -XUnboxedTuples on the command line.

Alternatives

I can't think of an alternative.

@toku-sa-n
Copy link
Collaborator

toku-sa-n commented Apr 5, 2024

Seems like HIndent 6.0.1 can detect the language extension. Could you give me an example that HIndent can't format?

Input

{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}

f :: (# Int, Int #) -> Int
f t = case t of
    (# x, _ #) -> x

Output

{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}

f :: (# Int, Int #) -> Int
f t =
  case t of
    (# x, _ #) -> x

@jmcarthur
Copy link
Contributor Author

jmcarthur commented Apr 6, 2024

It works in patterns but not in expressions, so I guess it's actually a bug. Perhaps I was wrong that this has anything to do with #419.

Input

f :: (# Int, Int #) -> (# Int, Int #)
f t = case t of
    (# x, y #) -> (# x, y #)

Output

f :: (# Int, Int #) -> (# Int, Int #)
f t =
  case t of
    (# x, y #) -> (x, y)

@toku-sa-n
Copy link
Collaborator

Thanks for the code. I can reproduce it, and I am fixing it now.

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