bluespec.com Forum Index bluespec.com
Bluespec Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Inferring Module types

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ...
View previous topic :: View next topic  
Author Message
Aninhumer



Joined: 20 Jul 2012
Posts: 9

PostPosted: Wed Aug 29, 2012 7:58 am    Post subject: Inferring Module types Reply with quote

Is it possible to have the type of a module inferred by the compiler, rather than requiring it to be explicitly stated using the square bracket notation?

I am currently trying to write some libraries to route various connections around without having to explicitly refer to them at every intermediate stage in the hierarchy. In particular I would like to be able to construct a ring network by adding Server-like interfaces to a collection held in module context, and then joining them together. Having to import and add [ModWithRing] or similar to every single module in the hierarchy seems a little silly, and also makes the library more confusing for people not familiar with custom modules. I would also like to implement a system which allows multiple such uses of context to be used together without conflicting, and at the moment this seems like it would probably necessitate a top level type synonym to list all the systems in use.

Since the compiler can deduce the type correctly anyway, it seems like omitting a specific module type could infer the type rather than asserting generality, without creating any problems for the type checker?
Back to top
View user's profile Send private message
quark
Site Admin


Joined: 02 Nov 2007
Posts: 500

PostPosted: Wed Aug 29, 2012 12:51 pm    Post subject: Re: Inferring Module types Reply with quote

I apologize, I'm not understanding your example. Can you provide some concrete code to look at?

As best I understand, the answer to your question is to just leave off the bracket type for any modules that are not specific to ModWithRing. When you leave off the bracket type, you are declaring a generic module that can be used inside any type of module. Which means that you can use it inside ModWithRing modules, too.

[When you leave off the bracket type, it's equivalent to declaring a module of type "m" with the proviso IsModule#(m,_).]

So when you say that "having to import and add [ModWithRing]" seems unnecessary, my response is to not import it and leave the brackets off. Does that not work for you?

If the module you're writing uses features that are specific to ModWithRing, then you are not declaring a generic module and you have to put the bracket type.

Note also that, while BSC does infer types, all top-level declarations are required to have types. So top-level functions must be given a type, and that includes top-level modules.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Designing with BSV's Rules, Interfaces, ... All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
bluespec.com topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP