Skip to content

Instantly share code, notes, and snippets.

Created June 15, 2017 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/7ff66d8e24a650eaffcdf0065966fe70 to your computer and use it in GitHub Desktop.
Save anonymous/7ff66d8e24a650eaffcdf0065966fe70 to your computer and use it in GitHub Desktop.
the description for this gist
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