{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE KindSignatures #-}
module Database.Relational.Compat
{-# DEPRECATED "backward compatibility definitions relational-query <= 0.9.*" #-} (
Projection, ListProjection,
ProductConstructor (..),
ProjectableFunctor, (|$|), ProjectableApplicative, (|*|),
ProjectableIdZip, rightId, leftId,
SqlProjectable (..), unsafeProjectSql,
ProjectableShowSql (..), unsafeShowSql,
pfmap, pap, pzero,
) where
import Data.Functor.ProductIsomorphic
(ProductIsoFunctor, (|$|), ProductIsoApplicative, (|*|),
ProductIsoEmpty, pureE, peRight, peLeft, )
import Data.Functor.ProductIsomorphic.Unsafe (ProductConstructor (..))
import Database.Relational hiding (unsafeShowSql', unsafeShowSql, unsafeProjectSqlTerms, unsafeProjectSql, )
import Database.Relational.Internal.String (showStringSQL, stringSQL)
import qualified Database.Relational.Record as Record
import qualified Database.Relational.Projectable as Projectable
{-# DEPRECATED Projection "Replaced by Record type" #-}
type Projection = Record
{-# DEPRECATED ListProjection "Replaced by RecordList type" #-}
type ListProjection = RecordList
{-# DEPRECATED ProjectableFunctor "use ProductIsoFunctor in Data.Functor.ProductIsomorphic instead of this. " #-}
type ProjectableFunctor = ProductIsoFunctor
{-# DEPRECATED ProjectableApplicative "use ProductIsoApplicative in Data.Functor.ProductIsomorphic instead of this. " #-}
type ProjectableApplicative = ProductIsoApplicative
{-# DEPRECATED ProjectableIdZip "use ProductIsoEmpty in Data.Functor.ProductIsomorphic instead of this. " #-}
type ProjectableIdZip p = ProductIsoEmpty p ()
{-# DEPRECATED rightId "use peRight in Data.Functor.ProductIsomorphic instead of this. " #-}
rightId :: ProjectableIdZip p => p (a, ()) -> p a
rightId = peRight
{-# DEPRECATED leftId "use peLeft in Data.Functor.ProductIsomorphic instead of this. " #-}
leftId :: ProjectableIdZip p => p ((), a) -> p a
leftId = peLeft
{-# DEPRECATED pfmap "use (|$|) in Data.Functor.ProductIsomorphic instead of this." #-}
pfmap :: ProductConstructor (a -> b) => (a -> b) -> Pi r a -> Pi r b
pfmap = (|$|)
{-# DEPRECATED pap "use (|*|) in Data.Functor.ProductIsomorphic instead of this." #-}
pap :: Pi r (a -> b) -> Pi r a -> Pi r b
pap = (|*|)
{-# DEPRECATED pzero "use pureE in Data.Functor.ProductIsomorphic instead of this." #-}
pzero :: Pi a ()
pzero = pureE
{-# DEPRECATED SqlProjectable "use 'SqlContext c => Record c a' instead of 'SqlProjectable p => p a'." #-}
class SqlProjectable p where
unsafeProjectSqlTerms :: [StringSQL]
-> p t
{-# DEPRECATED unsafeProjectSqlTerms "Use Database.Relational.unsafeProjectSqlTerms instead of this." #-}
instance SqlContext c => SqlProjectable (Record c) where
unsafeProjectSqlTerms = Projectable.unsafeProjectSqlTerms
{-# DEPRECATED unsafeProjectSql "Use Database.Relational.unsafeProjectSql instead of this." #-}
unsafeProjectSql :: SqlProjectable p => String -> p a
unsafeProjectSql = unsafeProjectSqlTerms . (:[]) . stringSQL
{-# DEPRECATED ProjectableShowSql "specialized type 'Record c' should be used instead of this constraint." #-}
class ProjectableShowSql p where
unsafeShowSql' :: p a -> StringSQL
{-# DEPRECATED unsafeShowSql' "Use Database.Relational.unsafeShowSql' instead of this." #-}
instance ProjectableShowSql (Record c) where
unsafeShowSql' = Record.unsafeStringSql
{-# DEPRECATED unsafeShowSql "Use Database.Relational.unsafeShowSql instead of this." #-}
unsafeShowSql :: ProjectableShowSql p => p a -> String
unsafeShowSql = showStringSQL . unsafeShowSql'