Re: higher-order functors
Dave Herman <[email protected]> Tue, 23 Jan 2007 23:29:05 -0800
| Newsgroups | gmane.comp.lang.sml.smlnj |
|---|---|
| Message-ID | <[email protected]> |
I managed to pare my code down to as simple an example I could that
generates the compiler error (see below).
Thanks,
Dave
----------
signature COROUTINE =
sig
type result
type C
val new : ((C * result) -> result) -> C
end;
funsig MK_COROUTINE (type result) = COROUTINE where type result = result;
functor MyCoroutine (type result) : COROUTINE =
struct
type result = result
datatype COROUTINE = Co
type C = COROUTINE
fun new f = Co
end
signature GENERATOR =
sig
type G
val make : (G -> unit) -> G
end
functor Generator(functor MkCoroutine : MK_COROUTINE) : GENERATOR =
struct
datatype signal = S
structure Coroutine : COROUTINE =
MkCoroutine (type result = signal)
datatype G = Generator of Coroutine.C
fun make f =
Generator (Coroutine.new (fn _ => S))
end
structure G = Generator(functor MkCoroutine = MyCoroutine)
-------------------------------------------------------------------------
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