interpolator-0.1.1: Runtime interpolation of environment variables in records using profunctors

Safe HaskellNone
LanguageHaskell2010

Data.Interpolation.TH

Synopsis

Documentation

makeInterpolatorSumInstance :: Name -> Q [Dec] Source #

Make an instance of Default for Interpolator of an ADT. Can't do it for an arbitrary Profunctor p because of partial functions. This splice is meant to be used in conjunction with makeAdaptorAndInstance for records as a way to project Default instances down to all leaves.

 data Foo' a b = Foo1 a | Foo2 b
 makeInterpolatorSumInstance 'Foo

 instance (Default Interpolator a1 b1, Default Interpolator a2 b2) => Default Interpolator (Foo' a1 a2) (Foo' b1 b2) where
   def = Interpolator $  case
     Foo1 x -> Foo1 $ runInterpolator def x
     Foo2 x -> Foo2 $ runInterpolator def x