Add Lens library for help simplify some verbose code in admin gui

This commit is contained in:
Eric Harding committed 2018-05-18 11:21:22 -04:00
1 parent 47b1e8f64d
commit e52fc2d196
2 files changed
+19

No files matched your search

+18
View File
@@ -0,0 +1,18 @@
module Lens
// Simple Lenses based on:
// http://bugsquash.blogspot.ch/2011/11/lenses-in-f.html
type Lens<'a,'b> = {
get: 'a -> 'b
set: 'b -> 'a -> 'a
}
with member l.update f a =
let v = l.get a
let newv = f v
l.set newv a
let inline (>>|) (l1:Lens<_,_>) (l2:Lens<_,_>) =
{ get = l1.get >> l2.get
set = l2.set >> l1.update }
+1
View File
@@ -17,6 +17,7 @@
<Compile Include="../../../../build/web/api/fable/OrderService.fable.fs" />
<Compile Include="../../../../build/web/api/fable/AdminService.fable.fs" />
<!-- Global to the app -->
<Compile Include="Lens.fs" />
<Compile Include="Global.fs" />
<Compile Include="Cmd.fs" />
<Compile Include="Controls/nbsp.fs" />