Skip to content

Instantly share code, notes, and snippets.

@bijancn
Created May 18, 2018 18:36
Show Gist options
  • Save bijancn/c2a3a456a12c0d0157e2dde3d9658f03 to your computer and use it in GitHub Desktop.
Save bijancn/c2a3a456a12c0d0157e2dde3d9658f03 to your computer and use it in GitHub Desktop.
Lessons learned from a fistful of functors
// Do you know this annoying feeling when you repeat a small function twice? Like
val x = X.doSomeStuff.notWorthRefactoring.butAnnoying
val y = Y.doSomeStuff.notWorthRefactoring.butAnnoying
// Now I can replace it with this satisfying pattern
val func = (_: String).doSomeStuff.notWorthRefactoring.butAnnoying
val (x, y) = (X, Y).bimap(func, func)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment