Skip to content

Commit

Permalink
Merge pull request lichess-org#42 from lenguyenthanh/inline-pipe
Browse files Browse the repository at this point in the history
Add inline pipe a replacement for standard lib pipe
  • Loading branch information
ornicar authored Jul 10, 2024
2 parents 4c2106e + a227b27 commit b2c4ed1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/src/main/scala/extensions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ object extensions:
def pps: A = kCombinator(x => pprintln(x.toString))
infix def pp(msg: String): A = kCombinator(x => pprintlnBoth(msg, x))

// copy from: https://github.com/Ichoran/kse3/blob/d3e3ec4771599204a22091ece804dd3491b31ea3/basics/src/Data.scala#L5506C1-L5507C49
/** replacement for standard lib pipe use inline to avoid boxing */
inline def pipe[B](inline f: A => B): B = f(a)

extension [A, B](m: Map[A, B])
// Add Map.mapKeys, similar to Map.mapValues
def mapKeys[C](f: A => C): Map[C, B] = m.map { (a, b) => (f(a), b) }
Expand Down

0 comments on commit b2c4ed1

Please sign in to comment.