[Haskell-cafe] How can I parameterize the Candidate?

Duane Johnson duane.johnson at gmail.com
Sun Mar 28 22:13:47 EDT 2010


Hello,

How can I parameterize the type of the following data class so that  
any type can be a Candidate?
   type Candidate = String
   data Poll = Poll [Candidate] [Ballot]

My initial thought was to simply put a type variable in place of  
Candidate, but that clearly won't work:

   data Poll = Poll [a] [Ballot]
 >>  Not in scope: type variable `a'
For context: I am building a voting library that addresses the issue  
of polarized American politics by implementing the Virtual Round Robin  
electoral method with a Maximum Majority Voting algorithm for breaking  
cycles.  The beginnings of the library are available at http://github.com/canadaduane/votelib/blob/master/vote.hs
What is a good approach to the parameterized type issue?  Thank you,
Duane Johnson


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20100328/f5260e5e/attachment.html


More information about the Haskell-Cafe mailing list