packages feed

persistable-record 0.5.1.1 → 0.5.2.0

raw patch · 5 files changed

+26/−6 lines, 5 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Database.Record.Instances: instance Database.Record.KeyConstraint.HasColumnConstraint Database.Record.KeyConstraint.NotNull GHC.Types.Int
+ Database.Record.Instances: instance Database.Record.Persistable.PersistableWidth GHC.Types.Int
- Database.Record.FromSql: class FromSql q a where recordFromSql = to <$> gFromSql
+ Database.Record.FromSql: class FromSql q a
- Database.Record.Persistable: class PersistableWidth a where persistableWidth = pmapConst (Sum . lastA) genericFieldOffsets where lastA a = a ! (snd $ bounds a)
+ Database.Record.Persistable: class PersistableWidth a
- Database.Record.ToSql: class PersistableWidth a => ToSql q a where recordToSql = from `mapToSql` gToSql
+ Database.Record.ToSql: class PersistableWidth a => ToSql q a

Files

ChangeLog.md view
@@ -1,5 +1,10 @@ <!-- -*- Markdown -*- --> +## 0.5.2.0++- check width of Int type and add instances. (backport)+- fix typo.+ ## 0.5.1.1  - Update this changelog.
persistable-record.cabal view
@@ -1,5 +1,5 @@ name:                persistable-record-version:             0.5.1.1+version:             0.5.2.0 synopsis:            Binding between SQL database values and haskell records. description:         This package contiains types to represent table constraints and                      interfaces to bind between SQL database values and Haskell records.
src/Database/Record/FromSql.hs view
@@ -60,7 +60,7 @@   foo =  ...   bar :: 'RecordFromSql' SqlValue Bar   bar =  ...-  baz :: 'RecordFromSql' SqlValue Bar+  baz :: 'RecordFromSql' SqlValue Baz   baz =  ... @ 
src/Database/Record/Instances.hs view
@@ -16,9 +16,10 @@ module Database.Record.Instances () where  import Data.Int (Int8, Int16, Int32, Int64)+import Database.Record.InternalTH (knownWidthIntType) import Database.Record.TH (deriveNotNullType) -$(fmap concat $ mapM deriveNotNullType+$(fmap concat $ mapM deriveNotNullType $   [ [t| Bool |]   , [t| Char |]   , [t| String |]@@ -26,4 +27,5 @@   , [t| Int16 |]   , [t| Int32 |]   , [t| Int64 |]-  ])+  ] +++  [ t | Just t <- [knownWidthIntType] ])
src/Database/Record/InternalTH.hs view
@@ -2,15 +2,17 @@ {-# LANGUAGE ConstraintKinds #-}  module Database.Record.InternalTH (-  defineTupleInstances+  defineTupleInstances,+  knownWidthIntType,   ) where  import Control.Applicative ((<$>))+import Data.Int (Int32, Int64) import Data.List (foldl') import Language.Haskell.TH   (Q, mkName, Name,    conT, varT, tupleT, appT, classP,-   Dec, instanceD, )+   TypeQ, Dec, instanceD, )  import Database.Record.Persistable (PersistableWidth) import Database.Record.FromSql (FromSql)@@ -43,3 +45,14 @@   [ persistableWidth n   , tupleInstance2 n ''FromSql   , tupleInstance2 n ''ToSql ]++knownWidthIntType :: Maybe TypeQ+knownWidthIntType+  | toI (minBound :: Int) == toI (minBound :: Int32) &&+    toI (maxBound :: Int) == toI (maxBound :: Int32)    =  Just [t| Int |]+  | toI (minBound :: Int) == toI (minBound :: Int64) &&+    toI (maxBound :: Int) == toI (maxBound :: Int64)    =  Just [t| Int |]+  | otherwise                                           =  Nothing+  where+    toI :: Integral a => a -> Integer+    toI = fromIntegral