]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.scl.runtime/scl/Lens.scl
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.scl.runtime / scl / Lens.scl
1 /// Lens ///
2
3 """
4 Laws:
5   set l (get l a) a) = a
6   get l (set l b a) = b
7   set l c (set l b a) = set l c a
8 """
9 data Lens a b = Lens (a -> b) (b -> a -> a)
10
11 get :: Lens a b -> a -> b
12 get (Lens f _) = f
13
14 set :: Lens a b -> b -> a -> a
15 set (Lens _ g) = g
16
17 /*instance Category Lens where
18     id = Lens id const
19     f . g = Lens (get f . get g)
20                  (\x y -> set g (set f x (get g y)) y)
21 */