Created
June 15, 2017 06:56
-
-
Save anonymous/7ff66d8e24a650eaffcdf0065966fe70 to your computer and use it in GitHub Desktop.
the description for this gist
This file contains 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 centimeterToMeterIso = Iso[Centimeter, Meter] { cm => | |
Meter(cm.whole / 100, cm.whole % 100) | |
}{ m => | |
Centimeter(m.whole * 100 + m.fraction) | |
} | |
centimeterToMeterIso.modify(m => m.copy(m.whole + 3))(Centimeter(155)) | |
// res: Centimeter(455) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment