Re: [Haskell-cafe] more sharing in generated code

2012-11-06 Thread Joachim Breitner
Hi, Am Montag, den 05.11.2012, 23:34 +0100 schrieb Peter Divianszky: Good remark, this can be solved with weak pointers, although I don't know how efficient they are. -- The next version of the proposal Replace every record update r' = r { x = y } with

Re: [Haskell-cafe] more sharing in generated code

2012-11-04 Thread Joachim Breitner
Hi, Am Samstag, den 03.11.2012, 11:26 +0100 schrieb Peter Divianszky: This can be implemented by replacing every record update r' = r { x = y } with r' = r { x = unsafePerformIO (cond-update r r' (x r) y) } where we keep the current record update mechanism and implement

[Haskell-cafe] more sharing in generated code

2012-11-03 Thread Peter Divianszky
Hi, I have a question about sharing at the Haskell run-time level. Suppose we have a record update r { x = f (r x)} and suppose that most of the time f returns it's argument unchanged. I have the following questions: 1. Does the generated code for the record update build an identical

Re: [Haskell-cafe] more sharing in generated code

2012-11-03 Thread Andreas Abel
On 03.11.12 10:05 AM, Peter Divianszky wrote: Suppose we have a record update r { x = f (r x)} and suppose that most of the time f returns it's argument unchanged. Recently I've heard about Q-combinators. Central idea: Change (f :: a - a) to (f' :: a - Maybe a) returning

Re: [Haskell-cafe] more sharing in generated code

2012-11-03 Thread Peter Divianszky
On 03/11/2012 10:47, Andreas Abel wrote: On 03.11.12 10:05 AM, Peter Divianszky wrote: Suppose we have a record update r { x = f (r x)} and suppose that most of the time f returns it's argument unchanged. Recently I've heard about Q-combinators. Central idea: Change (f :: a - a)

Re: [Haskell-cafe] more sharing in generated code

2012-11-03 Thread Peter Divianszky
On 03/11/2012 11:20, Peter Divianszky wrote: On 03/11/2012 10:47, Andreas Abel wrote: On 03.11.12 10:05 AM, Peter Divianszky wrote: Suppose we have a record update r { x = f (r x)} and suppose that most of the time f returns it's argument unchanged. Recently I've heard about

Re: [Haskell-cafe] more sharing in generated code

2012-11-03 Thread Dennis Felsing
On 2012-11-03T10:05+0100, Peter Divianszky wrote: Suppose we have a record update r { x = f (r x)} Hi Peter, I think you mean this: r { x = f (x r) } 1. Does the generated code for the record update build an identical record when f returns it's argument unchanged instead of sharing

Re: [Haskell-cafe] more sharing in generated code

2012-11-03 Thread Peter Divianszky
Hi Dennis, I think you mean this: r { x = f (x r) } Yes, I made a typo. Thanks for advising ghc-vis. In GHC: In your example a new record is built, but all its entries (x in this case) are shared. The problem is, that in case of nested records, if an inner record is updated, the