My program is using Uniplate.Data extensively, and want to improve its performance.
Currently I'm deriving Data
instances automatically using the DeriveDataTypeable
GHC extension.
{-# LANGUAGE DeriveDataTypeable #-}
import Data.Data
import Data.Generics.Uniplate.Data
data Expr = Val Int
| Neg Expr
| Add Expr Expr
deriving (Data,Typeable)
The Uniplate.Data package description recommend using Uniplate.Direct because of superior performance.
The latter requires writing explicit Uniplate
instances for data types, and recommend the Derive tool for that.
When trying to derive instances automatically using Derive
:
{-# LANGUAGE TemplateHaskell #-}
import Data.DeriveTH
import Data.Generics.Uniplate.Direct
data Expr = Val Int
| Neg Expr
| Add Expr Expr
$( derive makeUniplateDirect ''Expr )
I get the following error:
Exception when trying to run compile-time code:
Derivation of UniplateDirect does not yet support Template Haskell, requires info for Expr
Code: derive makeUniplateDirect ''Expr
Is there any other way of deriving Uniplate.Direct
instances automatically?
Thanks!