generics - F# - warning that I am not declaring type parameters explicitly -


given:

type service = object type services = concurrentdictionary<type, service> 

why this:

// if use form, compiler warning: type getservice<'t> = services -> 't let getservice:getservice<'t> = fun services ->     services.[typeof<'t>] :?> 't 

produce warning:

"the method or function 'getservice' should not given explicit type arguments because not declare type parameters explicity."

but not:

let getservice<'t> (services : services) =     services.[typeof<'t>] :?> 't 

example usage:

let someservice = services |> getservice<someservicetype> 

if want correct first version not warning, how change definition?

just give type parameter, error message suggests. should work:

let getservice<'t> : getservice<'t> = fun services ->     services.[typeof<'t>] :?> 't 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -