persistent-template 1.2.0.3 → 1.2.0.4
raw patch · 2 files changed
+9/−20 lines, 2 filesdep −th-orphans
Dependencies removed: th-orphans
Files
- Database/Persist/TH.hs +8/−18
- persistent-template.cabal +1/−2
Database/Persist/TH.hs view
@@ -51,10 +51,9 @@ ( ToJSON (toJSON), FromJSON (parseJSON), (.=), object , Value (Object), (.:), (.:?) )-import Control.Applicative (pure, (<*>), liftA2)+import Control.Applicative (pure, (<*>)) import Control.Monad.Logger (MonadLogger) import Database.Persist.Sql (sqlType)-import Language.Haskell.TH.Instances () -- | Converts a quasi-quoted syntax into a list of entity definitions, to be -- used as input to the template haskell generation code (mkPersist).@@ -89,16 +88,16 @@ where defsOrig = parse ps s -getSqlType :: [EntityDef ()] -> EntityDef () -> EntityDef DelayedSqlTypeExp+getSqlType :: [EntityDef ()] -> EntityDef () -> EntityDef SqlTypeExp getSqlType allEntities ent = ent { entityFields = map go $ entityFields ent } where- go :: FieldDef () -> FieldDef DelayedSqlTypeExp+ go :: FieldDef () -> FieldDef SqlTypeExp go field = do field- { fieldSqlType = DSTE final+ { fieldSqlType = final , fieldEmbedded = mEmbedded (fieldType field) } where@@ -136,13 +135,6 @@ typedNothing = SigE (ConE 'Nothing) mtyp st = VarE 'sqlType `AppE` typedNothing --data DelayedSqlTypeExp = DSTE { unDSTE :: SqlTypeExp }-instance Lift DelayedSqlTypeExp where- lift (DSTE SqlString') = return $ ConE 'SqlString'- lift (DSTE SqlInt64') = return $ ConE 'SqlInt64'- lift (DSTE (SqlTypeExp e)) = liftA2 AppE (return $ ConE 'SqlTypeExp) (lift e)- data SqlTypeExp = SqlTypeExp Exp | SqlString' | SqlInt64'@@ -153,7 +145,7 @@ -- | Create data types and appropriate 'PersistEntity' instances for the given -- 'EntityDef's. Works well with the persist quasi-quoter.-mkPersist :: MkPersistSettings -> [EntityDef SqlTypeExp] -> Q [Dec]+mkPersist :: MkPersistSettings -> [EntityDef SqlType] -> Q [Dec] mkPersist mps ents' = do x <- fmap mconcat $ mapM (persistFieldFromEntity mps) ents y <- fmap mconcat $ mapM (mkEntity mps) ents@@ -547,7 +539,7 @@ ] $ ConE 'Entity `AppE` VarE keyName `AppE` (ConE (sumConstrName mps t f) `AppE` VarE xName) -mkEntity :: MkPersistSettings -> EntityDef SqlTypeExp -> Q [Dec]+mkEntity :: MkPersistSettings -> EntityDef SqlType -> Q [Dec] mkEntity mps t = do t' <- lift t let nameT = unHaskellName $ entityHaskell t@@ -562,7 +554,7 @@ { fieldHaskell = HaskellName "Id" , fieldDB = entityID t , fieldType = FTTypeCon Nothing $ unHaskellName (entityHaskell t) ++ "Id"- , fieldSqlType = SqlInt64'+ , fieldSqlType = SqlInt64 , fieldEmbedded = Nothing , fieldAttrs = [] , fieldStrict = True@@ -873,8 +865,6 @@ lift' () = [|()|] instance Lift' SqlTypeExp where lift' = lift-instance Lift' DelayedSqlTypeExp where- lift' = lift pack' :: String -> Text pack' = pack@@ -949,7 +939,7 @@ -- forall . typ ~ FieldType => EntFieldName -- -- EntFieldName = FieldDef ....-mkField :: MkPersistSettings -> EntityDef a -> FieldDef SqlTypeExp -> Q (Con, Clause)+mkField :: MkPersistSettings -> EntityDef a -> FieldDef SqlType -> Q (Con, Clause) mkField mps et cd = do let con = ForallC []
persistent-template.cabal view
@@ -1,5 +1,5 @@ name: persistent-template-version: 1.2.0.3+version: 1.2.0.4 license: MIT license-file: LICENSE author: Michael Snoyman <michael@snoyman.com>@@ -20,7 +20,6 @@ , monad-control >= 0.2 && < 0.4 , text >= 0.5 && < 1.0 , transformers >= 0.2 && < 0.4- , th-orphans , containers , aeson , monad-logger