Re: Why can't arguments be levity polymorphic for inline functions?

2021-10-08 Thread Clinton Mead
Ben, The suggestion of erroring if the inline pragma was not there was just because I thought it would be better than silently doing something different. But that's just a subjective opinion, it's not core to what I'm proposing. Indeed there are two other options: 1. Make levity polymorphic

Re: Why can't arguments be levity polymorphic for inline functions?

2021-10-08 Thread Krzysztof Gogolewski
ehalf Of Clinton Mead > Sent: 08 October 2021 00:37 > To: ghc-devs@haskell.org > Subject: Why can't arguments be levity polymorphic for inline functions? > > > > Hi All > > > > Not sure if this belongs in ghc-users or ghc-devs, but it seemed devy enough > to put it her

RE: Why can't arguments be levity polymorphic for inline functions?

2021-10-08 Thread Simon Peyton Jones via ghc-devs
.com<mailto:simon.peytonjo...@gmail.com> instead. (For now, it just forwards to simo...@microsoft.com.) From: ghc-devs On Behalf Of Clinton Mead Sent: 08 October 2021 00:37 To: ghc-devs@haskell.org Subject: Why can't arguments be levity polymorphic for inline functions? Hi All Not sure if this

Re: Why can't arguments be levity polymorphic for inline functions?

2021-10-08 Thread Ben Gamari
Chris Smith writes: > On Fri, Oct 8, 2021 at 10:51 AM Ben Gamari wrote: > >> In my mind the fundamental problem with this approach is that it means >> that a program's acceptance by the compiler hinges upon pragmas. >> This is a rather significant departure from the status quo, where one >> can

Re: Why can't arguments be levity polymorphic for inline functions?

2021-10-08 Thread Richard Eisenberg
> On Oct 8, 2021, at 10:51 AM, Ben Gamari wrote: > In my mind the fundamental problem with this approach is that it means > that a program's acceptance by the compiler hinges upon pragmas. I think being able to ignore pragmas is a worthy goal, but one we're rather far short of, at the moment:

Re: Why can't arguments be levity polymorphic for inline functions?

2021-10-08 Thread Chris Smith
On Fri, Oct 8, 2021 at 10:51 AM Ben Gamari wrote: > In my mind the fundamental problem with this approach is that it means > that a program's acceptance by the compiler hinges upon pragmas. > This is a rather significant departure from the status quo, where one > can remove all pragmas and still

Re: Why can't arguments be levity polymorphic for inline functions?

2021-10-08 Thread Ben Gamari
Clinton Mead writes: > Hi All > > Not sure if this belongs in ghc-users or ghc-devs, but it seemed devy > enough to put it here. > > Section 6.4.12.1 > > of the GHC user manual points out, if we

Re: Why can't arguments be levity polymorphic for inline functions?

2021-10-08 Thread Richard Eisenberg
One significant problem is that {-# INLINE #-} functions are not actually always inlined! Specifically, if an inline-function is not passed all of its arguments, it will not be inlined. This poses a problem for levity-polymorphic functions, and GHC already does some special handling of the few

Re: Why can't arguments be levity polymorphic for inline functions?

2021-10-08 Thread Clinton Mead
Thanks for your reply Andreas. Just some further thoughts, perhaps we don't even require inline. Correct me if I'm wrong, but couldn't we compile even functions with levity polymorphic arguments by just boxing all the arguments? This would also mean the caller would have to box arguments before

Re: Why can't arguments be levity polymorphic for inline functions?

2021-10-08 Thread Andreas Klebinger
Hey Clinton, I think the state of things is best summarised it's in principle possible to implement. But it's unclear how best to do so or even if it's worth having this feature at all. The biggest issue being code bloat. As you say a caller could create it's own version of the function with

Why can't arguments be levity polymorphic for inline functions?

2021-10-07 Thread Clinton Mead
Hi All Not sure if this belongs in ghc-users or ghc-devs, but it seemed devy enough to put it here. Section 6.4.12.1 of the GHC user manual points out, if we allowed levity polymorphic arguments, then