Advertisement
Guest User

Untitled

a guest
May 24th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.70 KB | None | 0 0
  1.  
  2. type Thing<'a> = { value : 'a; name : string }
  3.  
  4. // generated for thing:
  5. [<AbstractClass>]
  6. type MThing<'ma>() =
  7.    abstract member value : 'ma
  8.     abstract member name : IMod<string>
  9.    
  10. type State = { thing : Thing<int>; other : plist<Thing<int>> }
  11.  
  12.  
  13. // generated for state
  14. [<System.Runtime.CompilerServices.Extension>]
  15. type private MThingOfIntForState(__initial : Thing<int>) =
  16.     inherit MThing<IMod<int>>()
  17.  
  18.     let mutable __current = __initial
  19.     let _value = ResetMod(__initial.value)
  20.     let _name = ResetMod(__initial.name)
  21.  
  22.     member x.Update(thing : Thing<int>) =
  23.         if not (System.Object.ReferenceEquals(__current, thing)) then
  24.             __current <- thing
  25.             _value.Update(thing.value)
  26.             _name.Update(thing.name)
  27.  
  28.     static member Create(thing : Thing<int>) =
  29.         MThingOfIntForState(thing) :> MThing<_>
  30.  
  31.     [<System.Runtime.CompilerServices.Extension>]
  32.     static member Update(m : MThing<IMod<int>>, v : Thing<int>) =
  33.         (unbox<MThingOfIntForState> m).Update(v)
  34.  
  35.     override x.value = _value :> IMod<_>
  36.     override x.name = _name :> IMod<_>
  37.  
  38. type MState(__initial : State) =
  39.    
  40.     let mutable __current = __initial
  41.     let _thing = MThingOfIntForState.Create __initial.thing
  42.     let _other = ResetMapList(__initial.other, (fun _ -> MThingOfIntForState.Create), MThingOfIntForState.Update)
  43.  
  44.     member x.thing = _thing
  45.     member x.other = _other :> alist<_>
  46.  
  47.     static member Create(s : State) =
  48.         MState(s)
  49.        
  50.     member x.Update(s : State) =
  51.         if not (System.Object.ReferenceEquals(__current, s)) then
  52.             __current <- s
  53.             _thing.Update(s.thing)
  54.             _other.Update(s.other)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement