I'm passing a record with the following structure to a Template Haskell function:
module Editor.App where
data WithMaybe
data WithoutMaybe
type family TypeSelector a b where
TypeSelector WithMaybe b = Maybe b
TypeSelector WithoutMaybe b = b
data MyRecord a = MyRecord
{ field1 :: TypeSelector a Int
, field2 :: TypeSelector a String
}
$(myTHFunction ''MyRecord)
Inside myTHFunction
I'm calling reify
and it is correctly giving me the following type-Info
:
TyConI
(DataD
[]
Editor.App.MyRecord
[KindedTV a_6989586621679348600 StarT]
Nothing
[RecC Editor.App.MyRecord
[ ( Editor.App.field1
, Bang NoSourceUnpackedness NoSourceStrictness
, AppT (AppT (ConT Editor.App.TypeSelector) (VarT a_6989586621679348600))
(ConT GHC.Types.Int) )
, ( Editor.App.field2
, Bang NoSourceUnpackedness NoSourceStrictness
, AppT (AppT (ConT Editor.App.TypeSelector) (VarT a_6989586621679348600))
(ConT GHC.Base.String) )
]
]
[]
)
However, in my application logic, I cannot proceed with an unapplied KindedTV a_6989586621679348600 StarT
. So, my question is:
- how do I "apply" this type-variable in TH
- or, how do I apply it before passing it to TH. I tried
$(myTHFunction ''(MyRecord SomeSelector))
but that doesn't work.