[Hugs-users] Hugs98-plus-Sept2006

Mark Hills mhills at cs.uiuc.edu
Sat Dec 9 10:12:39 EST 2006


I don't know the history behind changes of this nature, but it appears
that these names are no longer directly exported. Instead, they are used
by the system in the implementations of other functions which are
visible. If you try typing :browse Hugs.Prelude at the Hugs> prompt, you
will see that the names are not listed in those that are visible in this
module.

It seems like these names are mainly hooked in to support the
implementation of type class functions (methods). For instance, since
Int represents bounded integers, it is part of the type class Bounded.
If you look in the list of names you get from browsing Hugs.Prelude, you
will see that there are two names that look promising:

minBound :: Bounded a => a  -- class member
maxBound :: Bounded a => a  -- class member

You can then use these to get the same results you would get from
primMinInt and primMaxInt:

Hugs> (minBound)::Int
-2147483648
Hugs> (maxBound)::Int
2147483647

Similarly, with primCharToInt, Char is considered an Enum type, and
there is a function named fromEnum.

Hugs> fromEnum 'c'
99
Hugs> (toEnum 99)::Char
'c'

I think in many cases you should be able to browse around the Prelude.hs
file and figure out how to get access to the prim functions indirectly
like this. For instance, the portions of the Prelude that correspond to
the above are:

primitive primMinInt, primMaxInt :: Int

instance Bounded Int where
    minBound = primMinInt
    maxBound = primMaxInt

primitive primCharToInt :: Char -> Int
primitive primIntToChar :: Int -> Char

instance Enum Char where
    toEnum           = primIntToChar
    fromEnum         = primCharToInt

On my system at least, the Prelude.hs file with this information is in
/usr/lib/hugs/packages/hugsbase/Hugs. I'm not sure where it would be on
a Windows system, but I imagine there is a similar directory structure
(maybe under Program Files\Hugs or some such). I hope this helps.

Mark



Dave at haskell.org wrote:
> I am learning Haskell by reading the book _The Haskell Road to
> Logic, Maths and Programming_ and by using Hugs98_plus_sep2006 which
> I have downloaded, built and installed on my AMD 64-bit OpenBSD
> system.  The books says that Hugs will show the prompt 'Prelude>'
> initially until a script is loaded. The version of Hugs installed
> on my system shows initially the prompt 'Hugs>' and invoking several functions
> (primMinInt, primMaxInt, etc.) generate the error message to be undefined. Does Hugs
> still exhibit the behavior described in the book, or is there a
> problem with the newly ported Hugs on my system?
>
> /home/daf}hugs
> __   __ __  __  ____   ___      _________________________________________
> ||   || ||  || ||  || ||__      Hugs 98: Based on the Haskell 98 standard
> ||___|| ||__|| ||__||  __||     Copyright (c) 1994-2005
> ||---||         ___||           World Wide Web: http://haskell.org/hugs
> ||   ||                         Bugs: http://hackage.haskell.org/trac/hugs
> ||   || Version: September 2006 _________________________________________
>
> Haskell 98 mode: Restart with command line option -98 to enable extensions
>
> Type :? for help
> Hugs> primMinInt
> ERROR - Undefined variable "primMinInt"
> Hugs> primMaxInt
> ERROR - Undefined variable "primMaxInt"
> Hugs> :names *prim*Int
> Hugs.Prelude.primCharToInt Hugs.Prelude.primCmpInt Hugs.Prelude.primDivInt
> Hugs.Prelude.primEqInt Hugs.Prelude.primIntegerToInt Hugs.Prelude.primMaxInt
> Hugs.Prelude.primMinInt Hugs.Prelude.primMinusInt Hugs.Prelude.primModInt
> Hugs.Prelude.primMulInt Hugs.Prelude.primNegInt Hugs.Prelude.primPlusInt Hugs.Prelude.primPmInt
> Hugs.Prelude.primQrmInt Hugs.Prelude.primQuotInt Hugs.Prelude.primRemInt
> Hugs.Prelude.primShowsInt
> (17 names listed)
> Hugs> primCharToInt 'a'
> ERROR - Undefined variable "primCharToInt"
> Hugs>
>
>
> Thanks,
>
> Dave Feustel
> _______________________________________________
> 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