record 0.4.1 → 0.4.1.1
raw patch · 2 files changed
+22/−12 lines, 2 filesdep ~template-haskell
Dependency ranges changed: template-haskell
Files
- library/Record/TH.hs +19/−9
- record.cabal +3/−3
library/Record/TH.hs view
@@ -3,16 +3,25 @@ import BasePrelude hiding (Proxy) import GHC.TypeLits-import Language.Haskell.TH hiding (classP)+import Language.Haskell.TH -classP :: Name -> [Type] -> Pred+classPCompat :: Name -> [Type] -> Pred #if MIN_VERSION_template_haskell(2,10,0)-classP n tl = foldl AppT (ConT n) tl+classPCompat n tl = foldl AppT (ConT n) tl #else-classP = ClassP+classPCompat = ClassP #endif +instanceDCompat :: Cxt -> Type -> [Dec] -> Dec+#if MIN_VERSION_template_haskell(2,11,0) +instanceDCompat =+ InstanceD Nothing+#else+instanceDCompat =+ InstanceD+#endif+ recordTypeDec :: Bool -> Int -> Dec recordTypeDec strict arity = #if MIN_VERSION_template_haskell(2,11,0) @@ -78,7 +87,7 @@ fieldInstanceDec :: FieldInstanceDecMode -> Int -> Int -> Dec fieldInstanceDec mode arity fieldIndex =- InstanceD [] headType decs+ instanceDCompat [] headType decs where headType = foldl1 AppT @@ -143,9 +152,10 @@ recordStorableInstanceDec :: Bool -> Int -> Dec recordStorableInstanceDec strict arity =- InstanceD context (AppT (ConT (mkName "Storable")) recordType)- [sizeOfD, inlineP "sizeOf", alignmentD, inlineP "alignment"- , peekD, inlineP "peek", pokeD, inlineP "poke"]+ instanceDCompat+ context+ (AppT (ConT (mkName "Storable")) recordType)+ [sizeOfD, inlineP "sizeOf", alignmentD, inlineP "alignment", peekD, inlineP "peek", pokeD, inlineP "poke"] where name = recordName strict arity recordType =@@ -153,7 +163,7 @@ (VarT (mkName ("v" <> show i)))) (ConT name) [1 .. arity]- context = map (\i -> classP (mkName "Storable") [VarT (mkName ("v" <> show i))])+ context = map (\i -> classPCompat (mkName "Storable") [VarT (mkName ("v" <> show i))]) [1 .. arity] inlineP name = PragmaD $ InlineP (mkName name) Inline FunLike AllPhases -- Decs a_k = alignment, s_k = size, b_k = begin offset, e_k = end+1 offset
record.cabal view
@@ -1,7 +1,7 @@ name: record version:- 0.4.1+ 0.4.1.1 synopsis: Anonymous records description:@@ -53,9 +53,9 @@ Record build-depends: -- - template-haskell == 2.*,+ template-haskell >= 2.8 && < 2.12, -- transformers >= 0.2 && < 0.6, basic-lens == 0.0.*, base-prelude >= 0.1 && < 2,- base >= 4.6 && < 5+ base >= 4.6 && < 4.9