Talk:Haskell/Classes and types

Comment by Kevin S. Van Horn
Isn't the diagram at the end in error? There's no instance of MonadPlus IO.


 * Hmm... worth asking the wikibook at haskell dot org list. Maybe somebody can go fix it -- Kowey 16:31, 20 May 2007 (UTC)

I took the text discussing Haskell classes vs. OO classes out of its "note" box because it doesn't display properly on the Safari and Firefox web browsers -- the note box overlaps the table of contents, rendering the paragraph unreadable. -- Kevin S. Van Horn, 1 July 2007.

Typeclasses /= Interfaces
Be carefull to compare typeclasses to (Java-)interfaces.

I think it is the best way to make people understand typeclasses, by comparing it to structures in other languages, but those people who are coming from object-oriented languages might be confused about the "force to implement" functions, defined in a typeclass.

So I would say typeclasses are more (or equal) to abstract classes in java. I think this would make things easier for java programmers, becoming good Haskell experts :-)

Btw: I am not able to do this minor change in the article. Why can i only edit the Introduction-Part of the article?


 * Sure, go ahead. (Though keep in mind that we also want most of the text to be independent of other languages. That's because analogies can be more harmful than learning the concept from scratch).
 * You should be able to edit any part, look for [edit] links.
 * -- apfe&lambda;mus 08:12, 27 January 2011 (UTC)

Rock, paper, scissors
Should they be deriving Ord? --83.226.119.163 (discuss) 18:24, 17 March 2011 (UTC)

"Obviously x and y must be of the same type because you can't add different numbers together."

That's a pretty confusing statement. It sounds like we're trying to tell the reader that 1 + 2 is impossible, because 1 and 2 are different numbers. The author must have meant different numeric types, but even that is not obvious because most other programming languages let you do that.

Merge proposal
Merger rationale: "Classes and types" always looked a bit too short, and now that class constraints are informally introduced very early in the book there is very little reason for the content of this page to remain autonomous. Since there will likely be a few more pages on type classes in this part of the book, merging them will also contribute for a smoother structure. Finally, the proposal has this page as destination because "Classes and types" is a better final title than "Class declarations" (the latter can live on as a redirect). --Duplode (discuss • contribs) 15:25, 11 April 2012 (UTC)

Deriving
"You can only use deriving with a limited set of built-in classes." This is no longer true, see section 7.5.3 here: http://www.haskell.org/ghc/docs/7.4.2/html/users_guide/deriving.html#deriving-typeable

This is a topic that doesn't need to be in the core of a "Learning Haskell" book, but it certainly belongs in the appendix.

Standard classes diagram obsolete?
In the Standard classes section is a very nice diagram. In it, no dependency is shown between Eq and Ord. Yet the immediately preceding section, Class inheritance, describes how there is a dependency between those two classes. I suspect this may be due to the diagram coming from an old edition of the Haskell Report? Gwideman (discuss • contribs) 01:33, 8 February 2013 (UTC)


 * Well spotted! The SVG is fixed now; thank you. Duplode (discuss • contribs) 17:33, 17 August 2013 (UTC)

I think there is also an arrow missing from Fractional to RealFrac. (Sorry, I can't figure out how to edit it myself.) Davjam2 19 Feb 21.


 * Diagram updated, thanks! Duplode (discuss • contribs) 22:10, 19 February 2021 (UTC)

Foreign-looking type declaration
I don't recall seeing this kind of type declaration up until this article:

I'm not sure I understand the meaning of it. Are we naming constructor parameters? If so, for what purpose? Sgcb (discuss • contribs) 00:27, 6 June 2014 (UTC)


 * That is record syntax. It allows us to use the fields of the data type without having to know their position, and also provides convenient getter functions. We cover it in the More on datatypes chapter.--Duplode (discuss • contribs) 18:52, 6 June 2014 (UTC)


 * Oh, gosh, I do remember that now! Thanks for setting me straight Duplode :) Sgcb (discuss • contribs) 20:54, 6 June 2014 (UTC)


 * You're welcome :)--Duplode (discuss • contribs) 01:51, 7 June 2014 (UTC)

New Page, Focussing on Numbers?
Hello - I've been working on a page specifically about numbers. A draft is here. It's still WIP and currently has a few issues (including quite a lot of overlap with this and other pages. It's probably also too long.). I'd be happy to hear any opinions anyone has about it, but will continue with it for now. Thanks. --Davjam2