#if __GLASGOW_HASKELL__ >= 800
module Database.Relational.OverloadedProjection (
HasProjection (..),
) where
import GHC.OverloadedLabels (IsLabel(..))
import GHC.TypeLits (Symbol)
import Database.Record (PersistableWidth)
import Database.Relational.SqlSyntax (PI)
import Database.Relational.Pi (Pi)
import Database.Relational.Projectable ((!))
data PiLabel (l :: Symbol) = GetPi
class HasProjection l a b | l a -> b where
projection :: PiLabel l -> Pi a b
#if __GLASGOW_HASKELL__ >= 802
instance HasProjection l a b => IsLabel l (Pi a b) where
fromLabel = projection (GetPi :: PiLabel l)
instance (PersistableWidth a, HasProjection l a b)
=> IsLabel l (PI c a b) where
fromLabel = (! projection (GetPi :: PiLabel l))
#else
instance HasProjection l a b => IsLabel l (Pi a b) where
fromLabel _ = projection (GetPi :: PiLabel l)
instance (PersistableWidth a, HasProjection l a b)
=> IsLabel l (PI c a b) where
fromLabel _ = (! projection (GetPi :: PiLabel l))
#endif
#else
module Database.Relational.OverloadedProjection () where
#endif