typescastingf#symbolstype-signature

what does the # symbol mean in an f# function signature?


I have seen a function defined like this:

let private applyTarget (logger:#ILogger) ceiling target =
    logger.Debug "enforce ceiling"
    match target > ceiling with
    | true -> ceiling | false -> target

What does the # symbol mean in the signature?

Whats the difference between logger:ILogger and logger:#ILogger?


Solution

  • A type signature #t is called "flexible type", and is just shorthand for 'a when 'a :> t.

    That is, #t means "any subtype of t".