Created
April 15, 2020 10:15
-
-
Save VinceMacBuche/baa811846c4dca578b6e09458336af86 to your computer and use it in GitHub Desktop.
small example for Pierre
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val f: String => Int = (s => s.length) | |
val g : Int => String = (i => i.toString) | |
implicit class Pipe[A,B](f : A => B) { | |
def |>[C] (g : C => A) : C => B = f.compose(g) | |
} | |
implicit class Apply[A](a : A) { | |
def |>[B] (fun : A => B) : B = fun(a) | |
} | |
4 |> (f |> g) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment