Example from Microsoft F# documentation doesn't compile

Viewed 36

MS documentation: Use interfaces to group related operations

type Serializer =
    abstract Serialize<'T>: preserveRefEq: bool -> value: 'T -> string
    abstract Deserialize<'T>: preserveRefEq: bool -> pickle: string -> 'T

If I copy and paste that into an fsx script or a dotnet-interactive notebook, I'll get a compiler error that says:

This construct is deprecated: ':' is not permitted as a character in operator names and is reserved for future useF# Compiler(35)

What changes would I need to make in order to fix this example?

1 Answers

I think just adding a space before the colon fixes it:

type Serializer =
    abstract Serialize<'T> : preserveRefEq: bool -> value: 'T -> string
    abstract Deserialize<'T> : preserveRefEq: bool -> pickle: string -> 'T

This might be a compiler bug.

Related