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

The line-breaks setting for operators a bit off with type families #490

Open
michalrus opened this issue Mar 11, 2018 · 1 comment
Open

Comments

@michalrus
Copy link

This example:

type family Unprotect (api :: k) :: k where
  Unprotect (Verb a b c (Cookied d)) = Verb a b c d
  Unprotect (CookieProtect api) = Unprotect api
  Unprotect (a :<|> b) = Unprotect a :<|> Unprotect b
  Unprotect (a :> b) = a :> Unprotect b
  Unprotect a = a

will be formatted to:

type family Unprotect (api :: k) :: k where
  Unprotect (Verb a b c (Cookied d)) = Verb a b c d
  Unprotect (CookieProtect api) = Unprotect api
  Unprotect (a
             :<|> b) = Unprotect a
  :<|> Unprotect b
  Unprotect (a
             :> b) = a
  :> Unprotect b
  Unprotect a = a

which does not compile, as the 6th line of the result (in the 3rd recipe) should be indented more.

/cc @sighingnow

@michalrus
Copy link
Author

A temporary workaround would be to parenthesize RHS which results in compillable code:

type family Unprotect (api :: k) :: k where
  Unprotect (Verb a b c (Cookied d)) = Verb a b c d
  Unprotect (CookieProtect api) = Unprotect api
  Unprotect (a
             :<|> b) = (Unprotect a
                        :<|> Unprotect b)
  Unprotect (a
             :> b) = (a
                      :> Unprotect b)
  Unprotect a = a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants