Questions tagged [typeclass]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2 votes
1 answer

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 ...
Petras Purlys's user avatar
3 votes
1 answer

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-...
johnbakers's user avatar
10 votes
2 answers

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 ...
semicolon's user avatar
  • 285
11 votes
1 answer

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: -...
Herng Yi's user avatar
  • 323
5 votes
2 answers

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 ...
Carcigenicate's user avatar
2 votes
2 answers

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 ...
Display Name's user avatar
8 votes
2 answers

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?
Petr's user avatar
  • 5,517