I am writing a little machine learning engine on top of the orleans framework with orleankka. I need a parent child class relationship where the parent supports get, set, default constructor and serialization. My attempts have failed in F#.
Update: used interface now I just need to figure out serialization of the image channel object.
type imagechannel = int * int * char array[][]
type Iobject =
abstract Value : obj with get, set
abstract FromSerial : SerializationInfo -> StreamingContext -> unit
abstract ToSerial : SerializationInfo -> StreamingContext -> unit
type ImageChannel() =
let mutable value : option<imagechannel> = None
interface Iobject with
member this.Value with get() = value :> obj and set v = value <- v :?> option<imagechannel>
member this.FromSerial info context =
member this.ToSerial info context =
Context Code:
type ProcessorMessage =
| Eval of (Iobject -> Parms -> Iobject) * Parms
| New of Iobject
| Value
| Load of cache
| Save of cache
| Trans of string * (Iobject -> Parms -> Iobject) * Parms
type Processor() =
inherit Actor<ProcessorMessage>()
let mutable value :option<Iobject> = None
override this.Receive message reply = task {
match message with
| Eval(fn,p) -> value <- (fn value p)
| Load(cache) -> //deserialize value
| Save(cache) -> //serialize value
| New(v) -> value <- v
| Value -> reply value
| Trans(addr,fn,p) -> let proc = this.System.ActorOf(addr)
proc <! New (fn value p) |> ignore
}
Should I implement the serialize interface directly? How do I override the abstract value member with a different type? Any other suggestions?
I think you don't want brackets in your interface definition.
Should be