How is this Generic-based instance implementation optimized by GHC?

2015-08-22 Thread Ömer Sinan Ağacan
Hi all, I'm very confused by an optimization GHC is doing. I have this code: data Tree a = Leaf a | Branch (Tree a) (Tree a) deriving (Generic, Show, NFData) data Tree1 a = Leaf1 a | Branch1 (Tree1 a) (Tree1 a) deriving (Show) instance NFData a = NFData (Tree1 a) where

Re: How is this Generic-based instance implementation optimized by GHC?

2015-08-22 Thread José Pedro Magalhães
Hi there, GHC can often do a pretty good job at optimising generics. I wrote a paper that looks at that in detail: José Pedro Magalhães. Optimisation of Generic Programs through Inlining. In 24th Symposium on Implementation and Application of Functional Languages (IFL'12), 2013.

Re: How is this Generic-based instance implementation optimized by GHC?

2015-08-22 Thread Ömer Sinan Ağacan
Awesome, thanks for the pointer, Pedro. 2015-08-22 19:01 GMT-04:00 José Pedro Magalhães drei...@gmail.com: Hi there, GHC can often do a pretty good job at optimising generics. I wrote a paper that looks at that in detail: José Pedro Magalhães. Optimisation of Generic Programs through