Skip to content

Instantly share code, notes, and snippets.

@patryk-scalac-io
Created June 15, 2017 06:51
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 patryk-scalac-io/e893e29f8d4ade512f0eaf6800308d04 to your computer and use it in GitHub Desktop.
Save patryk-scalac-io/e893e29f8d4ade512f0eaf6800308d04 to your computer and use it in GitHub Desktop.
// Based directly on definition:
val stringPrism = Prism[Json, String]{
case JStr(v) => Some(v)
case _ => None
}(str => JStr(str))
// The same prism but defined using `partial` helper and succinct syntax for second argument:
val stringPrism = Prism.partial[Json, String]{case JStr(v) => v}(JStr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment