मैं पैरामीट्रिक प्रकार वाले मॉड्यूल के आधार पर फ़ंक्शन लिखने का तरीका जानने का प्रयास कर रहा हूं लेकिन मुझे कहीं भी कुछ भी नहीं मिल रहा है। मैंने जितनी ज्यादा हो सके समस्या को कम करने की कोशिश की और इस डमी उदाहरण के साथ समाप्त हो गया।पैरामैट्रिक स्थानीय रूप से अमूर्त प्रकार
module type Mappable = sig
type 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
end
let plus (type m) (module M : Mappable with type 'a t = 'a m) (xs : int m) =
M.map (fun x -> x + 1) xs
जो Error: Syntax error: module-expr expected
त्रुटि उत्पन्न करता है।
यदि मैं 'a
छोड़ देता हूं, तो मैं निम्न त्रुटि के साथ समाप्त होता हूं।
Error: In this `with' constraint, the new definition of t
does not match its original definition in the constrained signature:
Type declarations do not match: type t is not included in type 'a t
They have different arities.
ऐसा करने के लिए सही वाक्यविन्यास क्या है?