tag:blogger.com,1999:blog-21123659.post3026224908973163127..comments2014-08-24T08:38:43.131+02:00Comments on koweycode: monomorphism and the unintentional fibkoweyhttp://www.blogger.com/profile/11175806459477851520noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-21123659.post-25099124915355352812007-07-16T19:12:00.000+02:002007-07-16T19:12:00.000+02:00Well, the monomorphism restriction is really about...Well, the monomorphism restriction is really about preventing a let-bound name from having a polymorphic type. Maybe we should go back in time and call it the apolymorphism restriction?<BR/><BR/>As for the wikibook, maybe the best thing to do would be to not lie to the user. Say something like:<BR/><BR/>This failed because of a subtle rule of Haskell that's actually designed to protect you. Because Haskell is a strongly typed language, and because it's designed to make that strong typing transparent to programmers, it's possible for a lexical value such as 25 to have multiple possible values (one for each possible type.) For now, you can remember that the "monomorphism restriction" only lets there be a single type, and thus a single value, for a let binding. This keeps the language from duplicating values (wasting space on large values) and computations (wasting time on long computations) behind your back. If you really want to allow this duplication to occur, you'll need to supply a polymorphic type signature.Matthew Coxnoreply@blogger.comtag:blogger.com,1999:blog-21123659.post-35279240410672621452007-07-15T20:13:00.000+02:002007-07-15T20:13:00.000+02:00For quite some time (before I actually had a close...For quite some time (before I actually had a close look at what the MR was), I had expected "monomorphism" to mean exactly what it usually means in mathematics: an injective homomorphism f, or more generally, one which has the property that for any g1 and g2, if f . g1 = f . g2 then g1 = g2.<BR/><BR/>So it is a particularly unfortunate piece of terminology, seeing as it can initially confuse those with both a mathematical and computer science background. On the other hand, it's the only sensible thing to refer to the opposite of polymorphism.Cale Gibbardhttp://www.blogger.com/profile/02239068589033148700noreply@blogger.comtag:blogger.com,1999:blog-21123659.post-45020944148806678172007-07-15T17:11:00.000+02:002007-07-15T17:11:00.000+02:00Thanks for the comments. I'll note that this is f...Thanks for the comments. I'll note that this is for an introductory text trying to present what a variable is. So part of the point was to show the user how to say things like "let r = 25". As for "r ()", well that's probably going to be a bit non-obvious for the new reader.koweyhttp://www.blogger.com/profile/11175806459477851520noreply@blogger.comtag:blogger.com,1999:blog-21123659.post-36274946590271246822007-07-15T09:59:00.000+02:002007-07-15T09:59:00.000+02:002*pi*25 also works.I think the moral that you can ...2*pi*25 also works.<BR/><BR/>I think the moral that you can draw from this is:<BR/><BR/> "Explicit is better than implicit." <BR/><BR/>(<A HREF="http://www.python.org/dev/peps/pep-0020/" REL="nofollow">The Zen of Python</A> by Tim Peters).Tristram Brelstaffwww.tristram.squarespace.comnoreply@blogger.comtag:blogger.com,1999:blog-21123659.post-5371279276952969982007-07-15T09:21:00.000+02:002007-07-15T09:21:00.000+02:00it me might useful for the reader to notice thanle...it me might useful for the reader to notice than<BR/><BR/>let r () = 25<BR/>2 * pi * r ()<BR/><BR/>works.Anonymousnoreply@blogger.com