user2106839
user2106839

Reputation: 21

Passing a type fun<'a> in parameter?

How can I pass a type fun<'a> in parameter in F#?

Example -> type myClass(a : int, myDelegate : fun<'a>)
    let theFunc = myDelegate

Upvotes: 1

Views: 85

Answers (1)

John Palmer
John Palmer

Reputation: 25526

I think you want

type mytype<'a> (a:int,myDelegate:'a->unit) = 
    let theFunc = myDelegate

Alternatively, if fun is some type defined elsewhere you will need to use backtick notation as fun is a reserved word in F#

type mytype<'a> (a:int,myDelegate:``fun``<'a>) = 
    let theFunc = myDelegate

Upvotes: 4

Related Questions