Skip to content

Commit

Permalink
Merge pull request #94 from lucidsoftware/map-rowparser
Browse files Browse the repository at this point in the history
Add map and andThen override to RowParser
  • Loading branch information
tmccombs authored Jan 21, 2025
2 parents 959e783 + ed6d6f1 commit 4c171f9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion relate/src/main/scala/com/lucidchart/relate/RowParser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import java.time.Instant
import scala.collection.mutable
import scala.language.higherKinds

trait RowParser[A] extends (SqlRow => A) {
trait RowParser[A] extends (SqlRow => A) { self =>
def parse(row: SqlRow): A

def apply(row: SqlRow) = parse(row)

override def andThen[B](g: A => B): RowParser[B] = new RowParser[B] {
def parse(row: SqlRow): B = g(self.parse(row))
}

def map[B](f: A => B): RowParser[B] = andThen(f)
}

object RowParser {
Expand Down

0 comments on commit 4c171f9

Please sign in to comment.