From 1f67de67097daef8f52f0d5492af41791870330e Mon Sep 17 00:00:00 2001 From: Sebastian Mendez Date: Wed, 11 Mar 2015 02:01:04 +0100 Subject: [PATCH] Added support for template-haskell >= 2.10.0. For TH >= 2.10.0 instance contexts are simple types. This change applies to the instance for `Storable`. --- library/Record/Types.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/Record/Types.hs b/library/Record/Types.hs index a72ba29..6e4ebcd 100644 --- a/library/Record/Types.hs +++ b/library/Record/Types.hs @@ -93,8 +93,14 @@ return $ flip map [1 .. 24] $ \arity -> (VarT (mkName ("v" <> show i)))) (ConT typeName) [1 .. arity] +#if MIN_VERSION_template_haskell(2,10,0) + -- In TH with `ConstraintKinds` the context is just simply a type + context = map (\i -> AppT (ConT (mkName "Storable")) (VarT (mkName ("v" <> show i)))) + [1 .. arity] +#else context = map (\i -> ClassP (mkName "Storable") [VarT (mkName ("v" <> show i))]) [1 .. arity] +#endif nameE = VarE . mkName -- The sum of the sizes of all types sizeOfFun' n = foldr (\a b -> AppE (AppE (nameE "+") a) b) (LitE (IntegerL 0)) $