higher-order functors
Dave Herman <[email protected]>
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
I found the need for a higher-order functor like the following:
functor Generator(functor Coroutine(type result) : COROUTINE)
: GENERATOR =
struct
datatype signal = ...
structure C = Coroutine(type result = signal)
...
end
In other words, it takes an implementation of COROUTINE that's itself
parameterized over the result type, and instantiates that type at
`signal'. So a use would look like:
structure G = Generator(functor Coroutine = MyCoroutine)
What's a good workaround for this kind of use case? I'd like the
Coroutine module to be abstract in the type of values passed between
coroutines, and I'd like the Generator module to be abstract in the
implementation of Coroutines.
(Also, it turns out I can't just change the COROUTINE signature to use a
polymorphic type 'a coroutine for implementation reasons; one of the
implementations uses continuations in a way that has to be monomorphic.)
Thanks,
Dave
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV