[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

[Haskell-cafe] forall disappear from type signature

2012-11-03 Thread oleg
Takayuki Muranushi wrote: Today, I encountered a strange trouble with higher-rank polymorphism. It was finally solved by nominal typing. Was it a bug in type checker? lack of power in type inference? runDB :: Lens NetworkState RIB runDB = lens (f::NetworkState - RIB) (\x s - s { _runDB = x

[Haskell-cafe] Input Handling, Callbacks, State Machines

2012-11-03 Thread Daniel Trstenjak
Hi all, I'm currently struggling in the search for a nice abstraction for the input handling of a game (it's a simple platformer with rectangular platforms). One good example is the level editor of the game. When pressing the left mouse button the creation of a new platform is started. As long

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

Re: [Haskell-cafe] Input Handling, Callbacks, State Machines

2012-11-03 Thread Benjamin Edwards
This might be worth reading http://blog.sigfpe.com/2011/10/quick-and-dirty-reinversion-of-control.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe