.net - F# Generics Constraints -
i have method on class:
member this.getdbset<'tentity, 'tdto, 'tkey when 'tkey :> iequatable<'tkey> , 'tentity :> ientity<'tkey> , 'tentity : not struct , 'tdto :> idto<'tkey> , 'tentity : equality , 'tentity : null , 'tdto : equality , 'tdto : null , 'tkey : equality>(repository : baserepository<'tentity, 'tdto, 'tkey>) = repository.dbsetfuncgetter().invoke(uow.context()) but when build project error
this code not sufficiently generic. type variable 'tentity when 'tentity :> ientity<'tkey> , 'tentity : not struct , 'tentity : equality , 'tentity : null , 'tkey :> iequatable<'tkey> , 'tkey : equality not generalized because escape scope. but constraints there. missing something?
edit:
if need more code:
https://github.com/ar3sdevelopment/caelan.frameworks.biz/blob/fsharp/caelan.frameworks.biz/classes.fs
this open source project
i don't know why error message displayed code found workaround , committed on github project. can check diff on file because it's easier read describe it.
https://github.com/ar3sdevelopment/caelan.frameworks.biz/commit/22898671635b4667c8741853af9cc86910e1ff5a#diff-d5779b1053a390520d2a4a0c643f3d68
the link contains diff solves question i'll explain in next lines.
i solved workaround, don't know why displaying.
on repository class (the class of repository in question, not class of method) has these members:
let mutable dbsetfunc : func<dbcontext, dbset<'tentity>> = null fellow member this.dbsetfunc set (value) = dbsetfunc <- value fellow member this.dbsetfuncgetter() = dbsetfunc but generated error, found trying commenting them , changed them these
[<defaultvalue>] val mutable dbsetfunc : func<dbcontext, dbset<'tentity>> fellow member this.dbsetfunc set (value) = this.dbsetfunc <- value fellow member internal this.dbsetfuncgetter() = this.dbsetfunc and can't explain why solves error, @ to the lowest degree hope helps.
the method in question remains same.
.net generics f# constraints f#-3.0
No comments:
Post a Comment