[Haskell-cafe] Type classes, collections, sum types, closures, and a massive headache
therealkludgy at gmail.com
Tue Jan 29 03:35:13 CET 2013
On Mon, Jan 28, 2013 at 5:43 PM, Bob Hutchison <hutch-lists at recursive.ca>wrote:
> Now, this is how I got caught: it seems to be impossible to have
> collections of things with a common type class if they have different
> types. How is it that I've written that many lines of code in Haskell and
> I'm just noticing this now? (If I wasn't so annoyed, I'd look for something
> clever to reflect how loc count obviously doesn't mean much… but clever
> seems to be beyond me today).
> Is this true? Are there any GHC extensions that will let me around this?
I just encountered this recently myself. There is a GADT
extension  that may help. The greater abstraction appears to lie in
existential types .
That being said, I'm a beginner as well and haven't yet used these
extensions. So far I have found that my code is simplified by redefining
heterogeneous types in terms of homogeneous functions. If I have a class
that implements common methods, I will reorganize lists by common function
types rather than by class.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe