[Hugs-users] Hugs98-plus-Sept2006

Mark Hills mhills at cs.uiuc.edu
Sat Dec 9 17:17:09 EST 2006


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 at 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 at haskell.org
> http://www.haskell.org/mailman/listinfo/hugs-users
>   


More information about the Hugs-Users mailing list