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

Defunctionalization symbols should be given fixity declarations #323

Closed
RyanGlScott opened this issue Apr 20, 2018 · 5 comments
Closed

Defunctionalization symbols should be given fixity declarations #323

RyanGlScott opened this issue Apr 20, 2018 · 5 comments

Comments

@RyanGlScott
Copy link
Collaborator

singletons provides a promoted version of the familiar composition function:

(.) :: (b -> c) -> (a -> b) -> (a -> c)
infixr 9 (.)

The promoted version is given the name (:.) and (after #322) is given a fixity of infixr 9. However, you can't really take advantage of the fact that (:.) is infixr 9. Why? To do so, you'd need to be able to write something like this:

f :. g :. h

But those aren't fully saturated uses of (:.) (which is a type family that takes three arguments), so GHC will reject that. On the other hand, you can use defunctionalization symbols to write:

f .@#@$$$ g .@#@$$$ h

However, this will associate to the left, not the right! This is because while (:.) is given a fixity of infixr 9, none of its defunctionalization symbols are. It seems like they ought to, though, especially since that's effectively the only way to exploit this right-associativity.

@RyanGlScott
Copy link
Collaborator Author

Implementing this wouldn't be too hard. However, we would need to change significantly less code if we had #319 merged first, so this is blocked on that.

@RyanGlScott
Copy link
Collaborator Author

Never mind, this wasn't as bad as I thought it would be. See #327.

On the way, though, I discovered that there's more problems lurking beneath the surface. See #326.

@goldfirere
Copy link
Owner

Forgive me if I'm being dense, but is f .@#@$$$ g .@#@$$$ h at all useful? There's no call to Apply anywhere in there...

@RyanGlScott
Copy link
Collaborator Author

Forgive me if I'm being dense, but is f .@#@$$$ g .@#@$$$ h at all useful?

Sure. I frequently write types of the form Sigma a (f .@#@$$$ g .@#@$$$ h), whose second field would have the type Apply (f .@#@$$$ g .@#@$$$ h) x for some x :: a.

@goldfirere
Copy link
Owner

OK. Merge away, then. :)

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