What does usage at a non-uniform instantiation mean?

Viewed 170

I am unable to compile the following code:

open Genotype
open Genome

type IAgent =
    abstract member CrossoverA: Genome<'T> -> unit

type internal AgentMessage<'T> = 
  | GetEnergy of AsyncReplyChannel<int>
  | CrossoverMessage of Genome<'T>
  | CompareMessage of Genome<'T>

type Agent<'T>(initialLifeEnergy : int, genotype : IGenotype<'T>) =
    let LifeEnergy = initialLifeEnergy
    let mailbox = new MailboxProcessor<AgentMessage<'T>>(fun inbox ->
        let rec loop  =
            async {  
                    let! (msg) = inbox.Receive()
                    printfn "Message received: %O" msg
                    match msg with 
                        | GetEnergy reply -> 
                              reply.Reply(LifeEnergy)
                        | CrossoverMessage genome->
                            printfn "crossover"
                        | CompareMessage fenome ->
                            printfn "compare" 
                        }
        loop )
    do
        mailbox.Start()


    member this.CrossoverA(genomeIn: Genome<'T>)  = (this :> IAgent).CrossoverA(genomeIn: Genome<'T>) 
    interface IAgent with
        member this.CrossoverA(genomeIn: Genome<'T>)  = 
            printfn "Crossover"
            mailbox.Post(CrossoverMessage genomeIn)

There is an error in line member this.CrossoverA(genomeIn: Genome<'T>):

Error 1 The generic member 'CrossoverA' has been used at a non-uniform instantiation prior to this program point. Consider reordering the members so this member occurs first. Alternatively, specify the full type of the member explicitly, including argument types, return type and any additional generic parameters and constraints.

Error 2 One or more of the explicit class or function type variables for this binding could not be generalized, because they were constrained to other types

and also in line mailbox.Post(CrossoverMessage genomeIn):

Error 3 The type ''T' does not match the type ''a'

I an not using the variable ''a' anywhere in the project. Also, the name CrossoverA is used only in this file. I feel puzzled, other classes in the project were created with similar typing patterns and work well.

1 Answers
Related