let getLogicalWithDoubleLevelElement<'E when 'E :> DoubleLevelElement>
(logicalModifier : InletPosition * OutletPosition -> Logical)
(logical : Logical) =
I need logicalModifier
to be generic function with type the same type argument as getLogicalWithDoubleLevelElement
.
How to define that?
If you need to pass an explicitly polymorphic function as an argument, then the only way to do that in F# is to use a new type with a generic method:
type LogicalModifier =
abstract MakeLogical<'E when 'E :> DoubleLevelElement> : InletPosition * OutletPosition -> Logical
let getLogicalWithDoubleLevelElement<'E when 'E :> DoubleLevelElement>
(logicalModifier : LogicalModifier)
(logical : Logical) = ... logicalModifier.MakeLogical<'E> ...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.