You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Type inference should work without having to specify R in the below unless there are multiple valid bijectionsobjectLens {
defget[A,B](a: A)(implicitbij: Bijection[A,(B,_)]):B= bij(a)._1
defmodify[A,B,R](a: A)(update: B=>B)(implicitbij: Bijection[A,(B,R)]):A= {
valdecons= bij(a)
bij.invert((update(decons._1), decons._2))
}
defset[A,B,R](a: A, b: B)(implicitbij: Bijection[A,(B,R)]):A= {
valdecons= bij(a)
bij.invert((b, decons._2))
}
}
This relies on having good bijections from A into each of it's parts. It would be great if we could have a way to signify that (B,R) could really be any tuple of B with any other items (e.g. (B,R1,R2,R3...) would work.
The text was updated successfully, but these errors were encountered:
http://twanvl.nl/blog/haskell/isomorphism-lenses
I think something like:
This relies on having good bijections from A into each of it's parts. It would be great if we could have a way to signify that (B,R) could really be any tuple of B with any other items (e.g. (B,R1,R2,R3...) would work.
The text was updated successfully, but these errors were encountered: