skunk icon indicating copy to clipboard operation
skunk copied to clipboard

Nonterminating Compilation on wide Codec with mismatch types with Encoder

Open Tomczik76 opened this issue 5 years ago • 0 comments

Skunk version 0.0.20

I have an Codec that is 31 columns wide and if I create an Encoder that doesn't match the types the compiler doesn't terminate.

  import skunk._
  import skunk.implicits._
  import skunk.codec.all._
  import java.time.LocalDateTime

   val transactionCodec =
      text ~ // accountId: String
        text.opt ~ // accountOwner: Option[String]
        text.opt ~ // address: Option[String]
        float8 ~ // amount: Double
        timestamp.opt ~ // authorizedDate: Option[LocalDateTime]
        text.opt ~ // byOrderOf: Option[String]
        text ~ // categoryId: String
        text.opt ~ // city: Option[String]
        text.opt ~ // country: Option[String]
        timestamp ~ // date: LocalDateTime
        text.opt ~ // isoCurrencyCode: Option[String]
        float8.opt ~ // lat: Option[Double]
        float8.opt ~ // lon: Option[Double]
        text.opt ~ // merchantName: Option[String]
        text ~ // name: String
        text ~ // originalDescription: String
        text.opt ~ // payee: Option[String]
        text.opt ~ // payer: Option[String]
        text ~ // paymentChannel: String
        text.opt ~ // paymentMethod: Option[String]
        text.opt ~ // paymentProcessor: Option[String]
        bool ~ // pending: Boolean
        text.opt ~ // pendingTransactionId: Option[String]
        text ~ // postalCode: String,
        text.opt ~ // ppdId: Option[String],
        text.opt ~ // reason: Option[String]
        text.opt ~ // referenceNumber: Option[String]
        text.opt ~ // storeNumber: Option[String]
        text.opt ~ // transactionCode: Option[String]
        text ~ // transactionId: String
        text.opt ~ // unofficialCurrencyCode: Option[String]
        text // userId: String


    case class Transaction2(
    accountId: String,
    accountOwner: Option[String],
    address: Option[String],
    amount: Double,
    authorizedDate: Option[LocalDateTime],
    byOrderOf: Option[String],
    categoryId: String,
    city: Option[String],
    country: Option[String],
    date: LocalDateTime,
    isoCurrencyCode: Option[String],
    lat: Option[Double],
    lon: Option[Double],
    merchantName: Option[String],
    name: String,
    originalDescription: String,
    payee: Option[String],
    payer: Option[String],
    paymentChannel: String,
    paymentMethod: Option[String],
    paymentProcessor: Option[String],
    pending: Boolean,
    pendingTransactionId: Option[String],
    postalCode: String,
    ppdId: Option[String],
    reason: Option[String],
    referenceNumber: Option[String],
    storeNumber: Option[String],
    transactionCode: Option[String],
    transactionId: String,
    unofficialCurrencyCode: Option[String],
    userId: String
)    
    val transactionEncoder =
     transactionCodec.values.contramap((t: Transaction2) =>
        t.accountId ~
          t.accountOwner ~
          t.address ~
          t.amount ~
          t.authorizedDate ~
          t.byOrderOf ~
          t.categoryId ~
          t.city ~
          t.country ~
          t.date ~
          t.isoCurrencyCode ~
          t.lat  ~
          t.lon ~
          t.merchantName ~
          t.name ~
          t.originalDescription ~
          t.payee ~
          t.payer ~
          t.paymentChannel ~
          t.paymentMethod ~
          t.paymentProcessor ~
          t.pending ~
          t.pendingTransactionId ~
          t.postalCode ~
          t.ppdId ~
          t.reason ~
          t.referenceNumber ~
          t.storeNumber ~
          t.transactionCode ~
          t.transactionId ~
          t.unofficialCurrencyCode ~
          t.userId 
      )

This compiles fine in a console but when you change one of the types of the Encoder e.g. float8 -> float4, the compiler fails to terminate.

Tomczik76 avatar Dec 12 '20 04:12 Tomczik76