Re: higher-order functors

David MacQueen <[email protected]> Tue, 23 Jan 2007 14:14:25 -0600
Newsgroups gmane.comp.lang.sml.smlnj
Message-ID <[email protected]>
Dave,

I tried to fill out your example code sketch to get the sample code  
below,
which seems to compile ok in 110.61.  Could you send me a more
complete version of your code that causes the Compiler bug error report?

signature COROUTINE =
sig
   type result
   val f : result -> unit
end;

funsig MK_COROUTINE (type result) = COROUTINE where type result =  
result;

signature GENERATOR = sig end;

functor Generator (functor MkCoroutine : MK_COROUTINE) : GENERATOR =
struct
   datatype signal = S
   structure Coroutine : COROUTINE =
     MkCoroutine (type result = signal)
   val x = Coroutine.f S
end;

Regards,

Dave MacQueen

On Jan 23, 2007, at 1:13 PM, Dave Herman wrote:

> Sorry, I'm still struggling with this. I'm afraid I'm still new to the
> advanced module system features of SML.
>
>>   funsig COROUTINE (type result) = sig ... end
>>
>>   functor Generator (functor Coroutine : COROUTINE) : GENERATOR =  
>> struct
>> ... end
>
> I tried the following:
>
>      signature COROUTINE = sig type result ... end
>      funsig MK_COROUTINE (type result)
>
>      functor Generator (functor MkCoroutine : MK_COROUTINE) :  
> GENERATOR =
>      struct
>          datatype signal = ...
>          structure Coroutine : COROUTINE =
>              MkCoroutine (type result = signal)
>          ...
>      end
>
> But COROUTINE was too abstract since it didn't know that
> Coroutine.result = result. So I changed the declaration of structure
> Coroutine to:
>
>      structure Coroutine : COROUTINE where type result = signal =
>          MkCoroutine (type result = signal)
>
> But I got the error "type result does not match definitional
> specification". I couldn't figure out what this error means.
>
> At this point I was stabbing in the dark, but I tried moving the
> where-clause instead to the declaration of MK_COROUTINE:
>
>      funsig MK_COROUTINE (type result) = COROUTINE
>          where type result = result
>
> But then I got the compiler error:
>
>      Error: Compiler bug: LtyExtern: wrong TCs in tc_select
>
>      I
>
> Thanks again,
> 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
> _______________________________________________
> Smlnj-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/smlnj-list
>


-------------------------------------------------------------------------
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