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 

List Syntax

 
Post new topic   Reply to topic    bluespec.com Forum Index -> Contributed tidbits
View previous topic :: View next topic  
Author Message
Aninhumer



Joined: 20 Jul 2012
Posts: 9

PostPosted: Wed Jan 29, 2014 2:26 pm    Post subject: List Syntax Reply with quote

This library provides a more convenient way to construct Lists (and other sequence data structures) by using a typeclass trick from Haskell to allow type safe variadic functions.

The functions list(), listN() and vector() each take an arbitrary number of arguments and produce a corresponding data structure of the correct size containing these values. This means instead of:
Code:
cons(1,cons(2,cons(3,cons(4,Nil))))

One can instead simply write:
Code:
list(1,2,3,4)

The only potential downside is that the type machinery used may generate complicated error messages in the presence of otherwise simple type errors or ambiguities. So far I haven't noticed anything particularly confusing, but there may be edge cases I haven't encountered yet.

I make this available under the BSD licence.

For more information about the technique used to allow this see:
http://stackoverflow.com/questions/7828072/how-does-haskell-printf-work
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    bluespec.com Forum Index -> Contributed tidbits 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 cannot attach files in this forum
You cannot download files in this forum
bluespec.com topic RSS feed 


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