<commit_before>{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

#if __GLASGOW_HASKELL__ >= 710
#define __OVERLAPPABLE__ {-# OVERLAPPABLE #-}
#else
#define __OVERLAPPABLE__
{-# LANGUAGE OverlappingInstances #-}
#endif

module Opaleye.StreamBeneathTheHills.TF
    ( PGScalar
    , UnPGScalar
    , PG
    , UnPG

    , PGRep
    , ToPG
    , FromPG
    , pg

    , PGMap
    , UnPGMap
    , PGMapSnd
    , UnPGMapSnd
    )
where

-- aeson ---------------------------------------------------------------------
import           Data.Aeson (Value)


-- anonymous-data ------------------------------------------------------------
import           Data.Anonymous.Product (Product, Record, Tuple)
import           Data.Labeled (Field)


-- base ----------------------------------------------------------------------
import           Control.Applicative (Const)
import           Data.Functor.Identity (Identity)
import           Data.Int (Int16, Int32, Int64)


-- bytestring ----------------------------------------------------------------
import           Data.ByteString (ByteString)


-- case-insensitive ----------------------------------------------------------
import           Data.CaseInsensitive (CI)


-- opaleye -------------------------------------------------------------------
import           Opaleye.Column (Column, Nullable)
import           Opaleye.Constant (Constant, constant)
import           Opaleye.PGTypes
                     ( PGArray
                     , PGBool
                     , PGBytea
                     , PGCitext
                     , PGDate
                     , PGFloat4
                     , PGFloat8
                     , PGInt2
                     , PGInt4
                     , PGInt8
                     , PGJsonb
                     , PGText
                     , PGTime
                     , PGTimestamp
                     , PGTimestamptz
                     , PGUuid
                     )
import           Opaleye.RunQuery (QueryRunner)


-- opaleye-of-the-stream-beneath-the-hills -----------------------------------
import           Opaleye.StreamBeneathTheHills.Option (Option)


-- product-profunctors -------------------------------------------------------
import           Data.Profunctor.Product.Default (Default)


-- tagged --------------------------------------------------------------------
import           Data.Tagged (Tagged)


-- text ----------------------------------------------------------------------
import           Data.Text (Text)


-- time ----------------------------------------------------------------------
import           Data.Time.Calendar (Day)
import           Data.Time.Clock (UTCTime)
import           Data.Time.LocalTime (LocalTime, TimeOfDay)


-- uuid-types ----------------------------------------------------------------
import           Data.UUID.Types (UUID)


------------------------------------------------------------------------------
type family PGScalar (a :: *) :: * where
    PGScalar Bool = PGBool
    PGScalar ByteString = PGBytea
    PGScalar (CI Text) = PGCitext
    PGScalar Day = PGDate
    PGScalar Double = PGFloat8
    PGScalar Float = PGFloat4
    PGScalar Int16 = PGInt2
    PGScalar Int32 = PGInt4
    PGScalar Int64 = PGInt8
    PGScalar LocalTime = PGTimestamp
    PGScalar Text = PGText
    PGScalar TimeOfDay = PGTime
    PGScalar UTCTime = PGTimestamptz
    PGScalar UUID = PGUuid
    PGScalar Value = PGJsonb


------------------------------------------------------------------------------
type family UnPGScalar (a :: *) :: * where
    UnPGScalar PGBool = Bool
    UnPGScalar PGBytea = ByteString
    UnPGScalar PGCitext = (CI Text)
    UnPGScalar PGDate = Day
    UnPGScalar PGFloat8 = Double
    UnPGScalar PGFloat4 = Float
    UnPGScalar PGInt2 = Int16
    UnPGScalar PGInt4 = Int32
    UnPGScalar PGInt8 = Int64
    UnPGScalar PGTimestamp = LocalTime
    UnPGScalar PGText = Text
    UnPGScalar PGTime = TimeOfDay
    UnPGScalar PGTimestamptz = UTCTime
    UnPGScalar PGUuid = UUID
    UnPGScalar PGJsonb = Value


------------------------------------------------------------------------------
type family PG a :: * where
    PG () = ()
    PG (a, b) = (PG a, PG b)
    PG (a, b, c) = (PG a, PG b, PG c)
    PG (a, b, c, d) = (PG a, PG b, PG c, PG d)
    PG (a, b, c, d, e) = (PG a, PG b, PG c, PG d, PG e)
    PG (a, b, c, d, e, f) = (PG a, PG b, PG c, PG d, PG e, PG f)
    PG (a, b, c, d, e, f, g) = (PG a, PG b, PG c, PG d, PG e, PG f, PG g)
    PG (a, b, c, d, e, f, g, h) =
        (PG a, PG b, PG c, PG d, PG e, PG f, PG g, PG h)
    PG (a, b, c, d, e, f, g, h, i) =
        (PG a, PG b, PG c, PG d, PG e, PG f, PG g, PG h, PG i)
    PG (a, b, c, d, e, f, g, h, i, j) =
        (PG a, PG b, PG c, PG d, PG e, PG f, PG g, PG h, PG i, PG j)
    PG (Product g '[]) = Product g '[]
    PG (Tuple (a ': as)) = Tuple (PG a ': PGMap as)<commit_msg>Changed PGScalar to an open type family.<commit_after>{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}

#if __GLASGOW_HASKELL__ >= 710
#define __OVERLAPPABLE__ {-# OVERLAPPABLE #-}
#else
#define __OVERLAPPABLE__
{-# LANGUAGE OverlappingInstances #-}
#endif

module Opaleye.StreamBeneathTheHills.TF
    ( PGScalar
    , UnPGScalar
    , PG
    , UnPG

    , PGRep
    , ToPG
    , FromPG
    , pg

    , PGMap
    , UnPGMap
    , PGMapSnd
    , UnPGMapSnd
    )
where

-- aeson ---------------------------------------------------------------------
import           Data.Aeson (Value)


-- anonymous-data ------------------------------------------------------------
import           Data.Anonymous.Product (Product, Record, Tuple)
import           Data.Labeled (Field)


-- base ----------------------------------------------------------------------
import           Control.Applicative (Const)
import           Data.Functor.Identity (Identity)
import           Data.Int (Int16, Int32, Int64)


-- bytestring ----------------------------------------------------------------
import           Data.ByteString (ByteString)


-- case-insensitive ----------------------------------------------------------
import           Data.CaseInsensitive (CI)


-- opaleye -------------------------------------------------------------------
import           Opaleye.Column (Column, Nullable)
import           Opaleye.Constant (Constant, constant)
import           Opaleye.PGTypes
                     ( PGArray
                     , PGBool
                     , PGBytea
                     , PGCitext
                     , PGDate
                     , PGFloat4
                     , PGFloat8
                     , PGInt2
                     , PGInt4
                     , PGInt8
                     , PGJsonb
                     , PGText
                     , PGTime
                     , PGTimestamp
                     , PGTimestamptz
                     , PGUuid
                     )
import           Opaleye.RunQuery (QueryRunner)


-- opaleye-of-the-stream-beneath-the-hills -----------------------------------
import           Opaleye.StreamBeneathTheHills.Option (Option)


-- product-profunctors -------------------------------------------------------
import           Data.Profunctor.Product.Default (Default)


-- tagged --------------------------------------------------------------------
import           Data.Tagged (Tagged)


-- text ----------------------------------------------------------------------
import           Data.Text (Text)


-- time ----------------------------------------------------------------------
import           Data.Time.Calendar (Day)
import           Data.Time.Clock (UTCTime)
import           Data.Time.LocalTime (LocalTime, TimeOfDay)


-- uuid-types ----------------------------------------------------------------
import           Data.UUID.Types (UUID)


------------------------------------------------------------------------------
type family PGScalar (a :: *) :: *
type instance PGScalar Bool = PGBool
type instance PGScalar ByteString = PGBytea
type instance PGScalar (CI Text) = PGCitext
type instance PGScalar Day = PGDate
type instance PGScalar Double = PGFloat8
type instance PGScalar Float = PGFloat4
type instance PGScalar Int16 = PGInt2
type instance PGScalar Int32 = PGInt4
type instance PGScalar Int64 = PGInt8
type instance PGScalar LocalTime = PGTimestamp
type instance PGScalar Text = PGText
type instance PGScalar TimeOfDay = PGTime
type instance PGScalar UTCTime = PGTimestamptz
type instance PGScalar UUID = PGUuid
type instance PGScalar Value = PGJsonb


------------------------------------------------------------------------------
type family UnPGScalar (a :: *) :: *
type instance UnPGScalar PGBool = Bool
type instance UnPGScalar PGBytea = ByteString
type instance UnPGScalar PGCitext = (CI Text)
type instance UnPGScalar PGDate = Day
type instance UnPGScalar PGFloat8 = Double
type instance UnPGScalar PGFloat4 = Float
type instance UnPGScalar PGInt2 = Int16
type instance UnPGScalar PGInt4 = Int32
type instance UnPGScalar PGInt8 = Int64
type instance UnPGScalar PGTimestamp = LocalTime
type instance UnPGScalar PGText = Text
type instance UnPGScalar PGTime = TimeOfDay
type instance UnPGScalar PGTimestamptz = UTCTime
type instance UnPGScalar PGUuid = UUID
type instance UnPGScalar PGJsonb = Value


------------------------------------------------------------------------------
type family PG a :: * where
    PG () = ()
    PG (a, b) = (PG a, PG b)
    PG (a, b, c) = (PG a, PG b, PG c)
    PG (a, b, c, d) = (PG a, PG b, PG c, PG d)
    PG (a, b, c, d, e) = (PG a, PG b, PG c, PG d, PG e)
    PG (a, b, c, d, e, f) = (PG a, PG b, PG c, PG d, PG e, PG f)
    PG (a, b, c, d, e, f, g) = (PG a, PG b, PG c, PG d, PG e, PG f, PG g)
    PG (a, b, c, d, e, f, g, h) =
        (PG a, PG b, PG c, PG d, PG e, PG f, PG g, PG h)
    PG (a, b, c, d, e, f, g, h, i) =
        (PG a, PG b, PG c, PG d, PG e, PG f, PG g, PG h, PG i)
    PG (a, b, c, d, e, f, g, h, i, j) =
        (PG a, PG b, PG c, PG d, PG e, PG f, PG g, PG h, PG i, PG j)
    PG (Product g '[]) = Product g '[]
    PG (Tuple (a ': as)) = Tuple (PG a ': PGMap as)
{'fraction_non_alphanumeric': 0.2669225727928097, 'fraction_numerical': 0.006740941859376463, 'mean_word_length': 1.1720211468076454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5615093', 'n_tokens_mistral': 3096, 'n_tokens_neox': 3144, 'n_words': 937}