Questions tagged [typeclass]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer
177 views

Placing Haskell typeclass instances

I'd like to hear some pros and cons about where it's best to put Haskell typeclass instances. I identify 2 possible cases and can not decide for myself which one is best: Put the instances together ...
3 votes
1 answer
1k views

What is the difference between Applicative and Generative Modules, and Type Classes?

Reading the comments to this blog post made me realize I don't know much about some really interesting functional mechanisms between languages like Haskell, OCaml and Standard ML. I'd love a high-...
10 votes
2 answers
1k views

Why isn't Bounded a subclass of Enum in Haskell

It seems like any Bounded instance should have a sane implementation of Enum. I cannot personally think of a counterexample, although if someone comes up with one that isn't pathological then I will ...
  • 285
11 votes
1 answer
560 views

Using Haskell type classes to enforce commutativity

I want to define a type class for geometric objects that can be intersected together: class Intersect a b c | a b -> c where intersect :: a -> b -> c -- Language extensions: -...
  • 323
5 votes
2 answers
547 views

Proper use of typeclasses

I'm trying Haskell's Gloss module, and I found a a pattern of things required to properly display an object: Its position, dimensions, scale and Picture representation. This seemed like a good use ...
2 votes
2 answers
2k views

Is it possible to have Ad-Hoc polymorphism with runtime dispatch?

As I did understand, and as it's described here, ad-hoc polymorphism is limited to compile-time dispatch. That is, if we have a function that expects an argument that belongs to a typeclass, we must ...
8 votes
2 answers
768 views

Who invented Haskell's type classes?

Haskell's type classes are a very powerful tool and give Haskell a great expressive ability, compared to functional languages that don't have them. When were they invented, and who invented them?
  • 5,459