Skip to content

Commit

Permalink
Build context for Store instances on type constructors with higher kinds
Browse files Browse the repository at this point in the history
  • Loading branch information
facundominguez authored and mgsloan committed Aug 16, 2021
1 parent 1f1b476 commit 64c5591
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Data/Store/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -876,4 +876,4 @@ instance Store NameFlavour where
#endif

$(reifyManyWithoutInstances ''Store [''Info] (const True) >>=
mapM (\name -> return (deriveGenericInstance [] (ConT name))))
mapM deriveGenericInstanceFromName)
6 changes: 6 additions & 0 deletions src/Data/Store/TH/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Data.Store.TH.Internal
deriveManyStoreFromStorable
, deriveTupleStoreInstance
, deriveGenericInstance
, deriveGenericInstanceFromName
, deriveManyStorePrimVector
, deriveManyStoreUnboxVector
, deriveStore
Expand Down Expand Up @@ -262,6 +263,11 @@ deriveTupleStoreInstance n =
deriveGenericInstance :: Cxt -> Type -> Dec
deriveGenericInstance cs ty = plainInstanceD cs (AppT (ConT ''Store) ty) []

deriveGenericInstanceFromName :: Name -> Q Dec
deriveGenericInstanceFromName n = do
tvs <- map VarT . dtTvs <$> reifyDataType n
return $ deriveGenericInstance (map storePred tvs) (appsT (ConT n) tvs)

------------------------------------------------------------------------
-- Storable

Expand Down

0 comments on commit 64c5591

Please sign in to comment.