Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
erikd committed Jul 17, 2024
1 parent fe0c7ce commit 1bd504d
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions persistent-mysql/test/InsertDuplicateUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeOperators #-}

module InsertDuplicateUpdate where

Expand Down
1 change: 1 addition & 0 deletions persistent-test/src/CustomPrimaryKeyReferenceTest.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
-- This test is based on this issue: https://github.com/yesodweb/persistent/issues/421
-- The primary thing this is testing is the migration, thus the test code itself being mostly negligible.
Expand Down
1 change: 1 addition & 0 deletions persistent-test/src/DataTypeTest.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
module DataTypeTest
( specsWith
Expand Down
1 change: 1 addition & 0 deletions persistent-test/src/EmbedOrderTest.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-unused-top-binds #-}
module EmbedOrderTest (specsWith, embedOrderMigrate, cleanDB) where
Expand Down
2 changes: 1 addition & 1 deletion persistent-test/src/MigrationOnlyTest.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE TypeApplications, UndecidableInstances #-}
{-# LANGUAGE TypeApplications, TypeOperators, UndecidableInstances #-}

{-# OPTIONS_GHC -Wno-unused-top-binds #-}

Expand Down
1 change: 1 addition & 0 deletions persistent-test/src/MigrationTest.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module MigrationTest where

Expand Down
1 change: 1 addition & 0 deletions persistent-test/src/PersistUniqueTest.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
module PersistUniqueTest where

Expand Down
1 change: 1 addition & 0 deletions persistent/Database/Persist/Class/PersistConfig.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE TypeOperators #-}

module Database.Persist.Class.PersistConfig
( PersistConfig (..)
Expand Down
1 change: 1 addition & 0 deletions persistent/Database/Persist/Class/PersistStore.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE TypeOperators #-}
module Database.Persist.Class.PersistStore
( HasPersistBackend (..)
, withBaseBackend
Expand Down
1 change: 1 addition & 0 deletions persistent/Database/Persist/Sql/Orphan/PersistQuery.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TypeOperators #-}

{-# OPTIONS_GHC -fno-warn-orphans #-}

Expand Down
1 change: 1 addition & 0 deletions persistent/Database/Persist/Sql/Orphan/PersistStore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeOperators #-}

{-# OPTIONS_GHC -fno-warn-orphans #-}

Expand Down
1 change: 1 addition & 0 deletions persistent/Database/Persist/Sql/Types/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeOperators #-}

-- | Breaking changes to this module are not reflected in the major version
-- number. Prefer to import from "Database.Persist.Sql" instead. If you neeed
Expand Down
15 changes: 7 additions & 8 deletions persistent/Database/Persist/TH.hs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ import Data.Either
import qualified Data.HashMap.Strict as HM
import Data.Int (Int64)
import Data.Ix (Ix)
import Data.List (foldl')
import qualified Data.List as List
import Data.List.NonEmpty (NonEmpty(..))
import qualified Data.List.NonEmpty as NEL
Expand Down Expand Up @@ -1986,7 +1985,7 @@ fromValues entDef funName constructExpr fields = do

return $ normalClause
[ListP $ fmap VarP (x1:restNames)]
(foldl' (\exp (name, fpv) -> applyFromPersistValue fpv exp name) conApp (zip restNames mkPersistValues))
(List.foldl' (\exp (name, fpv) -> applyFromPersistValue fpv exp name) conApp (zip restNames mkPersistValues))

infixFromPersistValue applyE fpv exp name =
UInfixE exp applyE (fpv `AppE` VarE name)
Expand Down Expand Up @@ -2061,7 +2060,7 @@ mkEntity embedEntityMap entityMap mps preDef = do

let keyCon = keyConName entDef
constr =
foldl'
List.foldl'
AppE
(ConE keyCon)
(VarE . snd <$> keyFieldNames')
Expand Down Expand Up @@ -2475,7 +2474,7 @@ mkForeignKeysComposite mps entDef foreignDef
$ foreignFieldNames
$ unboundForeignFields foreignDef
mkKeyE =
foldl' AppE (maybeExp fNullable $ ConE reftableKeyName) fldsE
List.foldl' AppE (maybeExp fNullable $ ConE reftableKeyName) fldsE
fn =
FunD fname [normalClause [VarP recordVarName] mkKeyE]

Expand Down Expand Up @@ -2630,7 +2629,7 @@ mkUniqueKeys def = do

go :: [(FieldNameHS, Name)] -> UniqueDef -> Exp
go xs (UniqueDef name _ cols _) =
foldl' (go' xs) (ConE (mkConstraintName name)) (toList $ fmap fst cols)
List.foldl' (go' xs) (ConE (mkConstraintName name)) (toList $ fmap fst cols)

go' :: [(FieldNameHS, Name)] -> Exp -> FieldNameHS -> Exp
go' xs front col =
Expand Down Expand Up @@ -2953,7 +2952,7 @@ mkJSON mps (fixEntityDef -> def) = do
FunD 'parseJSON [ normalClause [] parseJSONBody ]
decoderImpl =
LamE [VarP obj]
(foldl'
(List.foldl'
(\x y -> InfixE (Just x) apE' (Just y))
(pureE `AppE` ConE conName)
pulls
Expand Down Expand Up @@ -2986,10 +2985,10 @@ mkJSON mps (fixEntityDef -> def) = do
return $ toJSONI : fromJSONI : entityJSONIs

mkClassP :: Name -> [Type] -> Pred
mkClassP cla tys = foldl AppT (ConT cla) tys
mkClassP cla tys = List.foldl AppT (ConT cla) tys

mkEqualP :: Type -> Type -> Pred
mkEqualP tleft tright = foldl AppT EqualityT [tleft, tright]
mkEqualP tleft tright = List.foldl AppT EqualityT [tleft, tright]

notStrict :: Bang
notStrict = Bang NoSourceUnpackedness NoSourceStrictness
Expand Down

0 comments on commit 1bd504d

Please sign in to comment.