[Haskell-cafe] How can I parameterize the Candidate?
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 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How can I parameterize the Candidate?
On 29 March 2010 13:13, Duane Johnson duane.john...@gmail.com wrote: How can I parameterize the type of the following data class so that any type can be a Candidate? data Poll = Poll [Candidate] [Ballot] data Poll a = Poll [a] [Ballot] data Poll = Poll [a] [Ballot] So close... -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How can I parameterize the Candidate?
Ah, just a character away. Thank you. Duane On Mar 28, 2010, at 9:21 PM, Ivan Miljenovic wrote: On 29 March 2010 13:13, Duane Johnson duane.john...@gmail.com wrote: How can I parameterize the type of the following data class so that any type can be a Candidate? data Poll = Poll [Candidate] [Ballot] data Poll a = Poll [a] [Ballot] data Poll = Poll [a] [Ballot] So close... -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe