tag:blogger.com,1999:blog-21123659.post6290150695372193467..comments2023-05-03T09:30:17.042+02:00Comments on koweycode: monomorphism reduxkoweyhttp://www.blogger.com/profile/11175806459477851520noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-21123659.post-73733984005071562852007-08-07T19:36:00.000+02:002007-08-07T19:36:00.000+02:00shachaf points out: "You can't expect "y = x + len...shachaf points out: "You can't expect "y = x + length [1,2,3]" to work, even if you add explicit type signatures, because pi can never be an Integral. A simple example, though, is "add1 = \x -> x + 1", which defaults to :: Integer -> Integer for me. Again,see the wiki page for the monomorphism restriction for some more examples."<BR/><BR/>(for which, thanks!)koweyhttps://www.blogger.com/profile/11175806459477851520noreply@blogger.comtag:blogger.com,1999:blog-21123659.post-8175431603315684912007-07-19T15:31:00.000+02:002007-07-19T15:31:00.000+02:00You mean like this?r = 25x = 2 * pi * rWhat's inte...You mean like this?<BR/>r = 25<BR/>x = 2 * pi * r<BR/><BR/>What's interesting is that if you do :t r, you find that its type is... Double. Monomorphism strikes again. Although I'm guessing that since we're compiling the whole thing, we can infer from pi that the type of x is Double, as is r's.<BR/><BR/>I'm not <I>entirely</I> sure I know what I'm talking about. I think somebody can come up with an example of the restriction biting you, even in a text file. Try for example y = x + length [1,2,3] (with the previous example). Doesn't even compile.koweyhttps://www.blogger.com/profile/11175806459477851520noreply@blogger.comtag:blogger.com,1999:blog-21123659.post-70369121669939553942007-07-19T15:08:00.000+02:002007-07-19T15:08:00.000+02:00Try to put the buggy code in a separate file, and ...Try to put the buggy code in a separate file, and :load them from ghci. It just works.<BR/><BR/>This seems to be a ghci issue (typing just-in-time is not as accurate, or something like that) rather that a Haskell issue.Anonymousnoreply@blogger.com