locally-abstract-type

First class Modules with parametric types (The type constructor F.f would escape its scope)

半世苍凉 提交于 2019-12-10 15:16:36
问题 I am currently playing around with modules, to see in which way they can be used in similar ways to Haskell type classes. Currently I am trying to play around with the functor type class: module type Functor = sig type 'a f val fmap : ('a -> 'b) -> ('a f -> 'b f) end module IdFunc = struct type 'a f = Id of 'a let fmap f = fun (Id a) -> Id (f a) let runId (Id a) = a end let outmap (module F : Functor) av = F.fmap f av However in this case outmap will not be typed correctly, the compiler