On Sat, Dec 09, 2006 at 03:32:22PM +0000, Neil Mitchell wrote:
As for the primitive operations, you shouldn't use them, ever. If you want to add two things use (+). They are merely an internal implementation detail, which I guess should never have been available to the user in the first place, and now isn't. I guess its a shame that a book that is only 2 years old is out of date, perhaps you might want to contact the authors to give them this information, so they can put it on a web page or something and save other people this confusion.
Yes, these were internal details of the Hugs implementation of the Prelude, and shouldn't have been exposed. They were only ever visible when the Prelude was the current module, and have been properly hidden since the November 2002 release.
But since they existed only to implement Haskell 98, there are always Haskell 98 alternatives, e.g. minBound::Int for primMinInt, as already mentioned.
I have now determined to my satisfaction that Hugs98-plus-Sept2006 has initialization problems concerning Prelude.hs and the use of the -P option. These problems may be peculiar to the port of Hugs to OpenBSD. In any event I have started poking around with gdb to try to figure out what's going on. (I actually can induce hugs to recognize the various prim functions that I initially had trouble with, but it's clear that Prelude processing does not work exactly as documented.) Dave Feustel
On Sat, Dec 09, 2006 at 07:20:41PM +0000, dfeustel@mindspring.com wrote:
I have now determined to my satisfaction that Hugs98-plus-Sept2006 has initialization problems concerning Prelude.hs and the use of the -P option. These problems may be peculiar to the port of Hugs to OpenBSD. In any event I have started poking around with gdb to try to figure out what's going on. (I actually can induce hugs to recognize the various prim functions that I initially had trouble with, but it's clear that Prelude processing does not work exactly as documented.)
I guess that you're trying to add /usr/lib/hugs/packages/hugsbase/Hugs to the search path. This isn't supposed to work, because that directory isn't the root of a module hierarchy: each file X.hs in there contains a module Hugs.X, not X. It's the parent of that directory that is a module hierarchy, and it's already in the search path. If you're determined to use these prim* functions (though you shouldn't because they're internal, and there are Haskell 98 equivalents of each of them), you can approximate the pre-2002 Hugs Prelude with Hugs> :m Hugs.Prelude Hugs.Prelude> primMaxInt 2147483647 There are no guarantees that it will work in the future, though.
Another useful option may be to just create a module with your own versions of the various prim functions. So, create something like this: module Prims where primMaxInt :: Int primMaxInt = maxBound primMinInt :: Int primMinInt = minBound primCharToInt :: Char -> Int primCharToInt c = fromEnum c primIntToChar :: Int -> Char primIntToChar n = toEnum etc... Then, just use this in whatever code you are writing: module MyFile where import Prims canAddOne :: Int -> Bool canAddOne n = if n < primMaxInt then True else False This way you should be able to use the code examples from the book fairly directly. Mark Ross Paterson wrote:
On Sat, Dec 09, 2006 at 07:20:41PM +0000, dfeustel@mindspring.com wrote:
I have now determined to my satisfaction that Hugs98-plus-Sept2006 has initialization problems concerning Prelude.hs and the use of the -P option. These problems may be peculiar to the port of Hugs to OpenBSD. In any event I have started poking around with gdb to try to figure out what's going on. (I actually can induce hugs to recognize the various prim functions that I initially had trouble with, but it's clear that Prelude processing does not work exactly as documented.)
I guess that you're trying to add /usr/lib/hugs/packages/hugsbase/Hugs to the search path. This isn't supposed to work, because that directory isn't the root of a module hierarchy: each file X.hs in there contains a module Hugs.X, not X. It's the parent of that directory that is a module hierarchy, and it's already in the search path.
If you're determined to use these prim* functions (though you shouldn't because they're internal, and there are Haskell 98 equivalents of each of them), you can approximate the pre-2002 Hugs Prelude with
Hugs> :m Hugs.Prelude Hugs.Prelude> primMaxInt 2147483647
There are no guarantees that it will work in the future, though.
_______________________________________________ Hugs-Users mailing list Hugs-Users@haskell.org http://www.haskell.org/mailman/listinfo/hugs-users
participants (3)
-
dfeustel@mindspring.com -
Mark Hills -
Ross Paterson