public static Lens <HashSet <A>, HashSet <A> > map <B>(Lens <A, A> lens) => Lens <HashSet <A>, HashSet <A> > .New( Get : la => la.Map(lens.Get), Set : lb => la => { foreach (var item in lb) { la = la.Find(item).Match(Some: x => la.AddOrUpdate(lens.Set(x, item)), None: () => la); } return(la); });
public static Lens <Arr <A>, Arr <B> > map <B>(Lens <A, B> lens) => Lens <Arr <A>, Arr <B> > .New( Get : la => la.Map(lens.Get), Set : lb => la => la.Zip(lb).Map(ab => lens.Set(ab.Item2, ab.Item1)).ToArr() );
public static State <A, Unit> put <A, B>(Lens <A, B> la, B value) => from a in get <A>() from _ in put(la.Set(value, a)) select unit;