mirror of
https://github.com/khibino/haskell-relational-record.git
synced 2024-11-25 08:19:14 +03:00
Merge b168e4b50e
into 2805670712
This commit is contained in:
commit
83acf2827b
@ -36,6 +36,11 @@ tested-with: GHC == 9.6.2
|
|||||||
, GHC == 7.4.1, GHC == 7.4.2
|
, GHC == 7.4.1, GHC == 7.4.2
|
||||||
extra-source-files: ChangeLog.md
|
extra-source-files: ChangeLog.md
|
||||||
|
|
||||||
|
flag IsLabel
|
||||||
|
default: True
|
||||||
|
manual: True
|
||||||
|
description: Define an IsLabel instance for Database.Relational.Typed.Record.PI
|
||||||
|
|
||||||
library
|
library
|
||||||
exposed-modules:
|
exposed-modules:
|
||||||
Database.Relational.Arrow
|
Database.Relational.Arrow
|
||||||
@ -142,6 +147,9 @@ library
|
|||||||
ghc-options: -Wnoncanonical-monadfail-instances
|
ghc-options: -Wnoncanonical-monadfail-instances
|
||||||
|
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
|
if flag(IsLabel)
|
||||||
|
ghc-options: -DISLABEL
|
||||||
|
|
||||||
|
|
||||||
test-suite sqls
|
test-suite sqls
|
||||||
build-depends: base <5
|
build-depends: base <5
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
{-# LANGUAGE MultiParamTypeClasses #-}
|
{-# LANGUAGE MultiParamTypeClasses #-}
|
||||||
{-# LANGUAGE FlexibleInstances #-}
|
{-# LANGUAGE FlexibleInstances #-}
|
||||||
{-# LANGUAGE FlexibleContexts #-}
|
{-# LANGUAGE FlexibleContexts #-}
|
||||||
|
{-# LANGUAGE TypeFamilies #-}
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ >= 800
|
#if __GLASGOW_HASKELL__ >= 800
|
||||||
-- |
|
-- |
|
||||||
@ -20,6 +21,7 @@
|
|||||||
--
|
--
|
||||||
-- This module provides interfaces of overloaded projections.
|
-- This module provides interfaces of overloaded projections.
|
||||||
module Database.Relational.OverloadedProjection (
|
module Database.Relational.OverloadedProjection (
|
||||||
|
PiLabel(..),
|
||||||
HasProjection (..),
|
HasProjection (..),
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -40,23 +42,23 @@ class HasProjection l a b | l a -> b where
|
|||||||
projection :: PiLabel l -> Pi a b
|
projection :: PiLabel l -> Pi a b
|
||||||
|
|
||||||
#if __GLASGOW_HASKELL__ >= 802
|
#if __GLASGOW_HASKELL__ >= 802
|
||||||
-- | Derive 'IsLabel' instance from 'HasProjection'.
|
#define FROM_LABEL fromLabel
|
||||||
instance HasProjection l a b => IsLabel l (Pi a b) where
|
|
||||||
fromLabel = projection (GetPi :: PiLabel l)
|
|
||||||
|
|
||||||
-- | Derive 'PI' label.
|
|
||||||
instance (PersistableWidth a, HasProjection l a b)
|
|
||||||
=> IsLabel l (PI c a b) where
|
|
||||||
fromLabel = (! projection (GetPi :: PiLabel l))
|
|
||||||
#else
|
#else
|
||||||
|
#define FROM_LABEL fromLabel _
|
||||||
|
#endif
|
||||||
|
|
||||||
|
instance l ~ l' => IsLabel l (PiLabel l') where -- a type equality constraint makes better type inference
|
||||||
|
FROM_LABEL = GetPi
|
||||||
|
|
||||||
-- | Derive 'IsLabel' instance from 'HasProjection'.
|
-- | Derive 'IsLabel' instance from 'HasProjection'.
|
||||||
instance HasProjection l a b => IsLabel l (Pi a b) where
|
instance HasProjection l a b => IsLabel l (Pi a b) where
|
||||||
fromLabel _ = projection (GetPi :: PiLabel l)
|
FROM_LABEL = projection (GetPi :: PiLabel l)
|
||||||
|
|
||||||
|
#if defined(ISLABEL)
|
||||||
-- | Derive 'PI' label.
|
-- | Derive 'PI' label.
|
||||||
instance (PersistableWidth a, HasProjection l a b)
|
instance (PersistableWidth a, HasProjection l a b)
|
||||||
=> IsLabel l (PI c a b) where
|
=> IsLabel l (PI c a b) where
|
||||||
fromLabel _ = (! projection (GetPi :: PiLabel l))
|
FROM_LABEL = (! projection (GetPi :: PiLabel l))
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
module Database.Relational.OverloadedProjection () where
|
module Database.Relational.OverloadedProjection () where
|
||||||
|
Loading…
Reference in New Issue
Block a user