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
Post a Comment