type MpCalc<'a> = { add: 'a -> 'a -> 'a; min: 'a -> 'a -> 'a; }
type Mp<'a> =
struct
val value: 'a
val calc: MpCalc<'a>
new(v, c) = { value = v; calc = c }
static member (+) (x: Mp<'a>, y: Mp<'a>) =
new Mp<_>(x.calc.min x.value y.value, x.calc)
static member (*) (x: Mp<'a>, y: Mp<'a>) =
new Mp<_>(x.calc.add x.value y.value, x.calc)
end
let inline toMp v = new Mp<_>(v, { add = (+); min = Operators.min; })
[<EntryPoint>]
let main argv =
printfn "1 + 1 = %A" ((toMp 1) + (toMp 1)).value
printfn "2 + 3 = %A" ((toMp 2) + (toMp 3)).value
printfn "2 * 3 = %A" ((toMp 2) * (toMp 3)).value
printfn "2 * 0 = %A" ((toMp 2) * (toMp 0)).value
printfn "3.0 + infinity = %A" ((toMp 3.0) + (toMp Operators.infinity)).value
printfn "3.0 * infinity = %A" ((toMp 3.0) * (toMp Operators.infinity)).value
0
dHlwZSBNcENhbGM8J2E+ID0geyBhZGQ6ICdhIC0+ICdhIC0+ICdhOyBtaW46ICdhIC0+ICdhIC0+ICdhOyB9Cgp0eXBlIE1wPCdhPiA9CiAgICBzdHJ1Y3QKICAgICAgICB2YWwgdmFsdWU6ICdhCiAgICAgICAgdmFsIGNhbGM6IE1wQ2FsYzwnYT4KICAgICAgICBuZXcodiwgYykgPSB7IHZhbHVlID0gdjsgY2FsYyA9IGMgfQogICAgICAgIHN0YXRpYyBtZW1iZXIgKCspICh4OiBNcDwnYT4sIHk6IE1wPCdhPikgPQogICAgICAgICAgICBuZXcgTXA8Xz4oeC5jYWxjLm1pbiB4LnZhbHVlIHkudmFsdWUsIHguY2FsYykKICAgICAgICBzdGF0aWMgbWVtYmVyICgqKSAoeDogTXA8J2E+LCB5OiBNcDwnYT4pID0KICAgICAgICAgICAgbmV3IE1wPF8+KHguY2FsYy5hZGQgeC52YWx1ZSB5LnZhbHVlLCB4LmNhbGMpCiAgICBlbmQKCmxldCBpbmxpbmUgdG9NcCB2ID0gbmV3I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