{-# OPTIONS_GHC -fglasgow-exts #-} {-# LANGUAGE TemplateHaskell #-} -- Main module: testing optimization of gmap id module Main where import Regular import Logic test :: (f ~ PF a, GMap f, Regular a) => a -> a test x = to (gmap id (from x)) -- With -O1 -funfolding-creation-threshold=500 -funfolding-use-threshold=80, -- test1 gets simplified to |id| test1 :: Logic -> Logic test1 x = to (gmap id (from x)) -- With -O1 -funfolding-creation-threshold=500 -funfolding-use-threshold=80, -- test2 gets simplified to |F :->: T| test2 = test (F :->: T) -- With -O1, test3 gets simplified to |to.from| -- With -O1 -funfolding-use-threshold=50, it gets simplified to |id| test3 :: Logic -> Logic test3 x = to (gmap id (from x)) -- test4 doesn't, which makes sense test4 x = to (gmap id (from x)) main = print [test1 (Var "myvar"), test2]