-
Notifications
You must be signed in to change notification settings - Fork 157
/
Void.scala
32 lines (26 loc) · 923 Bytes
/
Void.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright (c) 2018 by Rob Norris
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT
package skunk
import skunk.data.Type
import cats.data.State
import cats.implicits._
/**
* A singly-inhabited type representing arguments to a parameterless statement.
* @group Codecs
*/
sealed trait Void
/** @group Companions */
case object Void extends Void {
val codec: Codec[Void] =
new Codec[Void] {
override def encode(a: Void): List[Option[String]] = Nil
override def decode(index: Int, ss: List[Option[String]]): Either[Decoder.Error, Void.type ] =
ss match {
case Nil => Void.asRight
case _ => Left(Decoder.Error(index, 0, s"Expected no values, found $ss"))
}
override val types: List[Type] = Nil
override val sql: State[Int, String] = "".pure[State[Int, ?]]
}
}