Skip to content

Commit

Permalink
Added support for template-haskell >= 2.10.0.
Browse files Browse the repository at this point in the history
For TH >= 2.10.0 instance contexts are simple types. This change applies
to the instance for `Storable`.
  • Loading branch information
rabipelais committed Mar 11, 2015
1 parent 299f94b commit 1f67de6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions library/Record/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)) $
Expand Down

0 comments on commit 1f67de6

Please sign in to comment.