Haskell Graphics Lib problem
Henrik Nilsson
nilsson@cs.yale.edu
Fri, 16 Feb 2001 00:09:11 -0500
Hi Don,
> I just bought 'The Haskell School of Expression', so I downloaded the
> latest version of Hugs98, February 2001, and the latest version of the
> Hugs Graphics Library, 2.0.3.
>
> Since the documentation mentioned building on Linux, I built and
> installed hugs98, ran some tests and felt it was okay. This is on a
> Redhat Linux 6.0 installation.
>
> Then I built the Hugs Graphics Library, and tried to run the first test
> suggested:
...
> ERROR graphics-2.0.3/lib/x11/Graphics_Utilities.hs:73 - Illegal type
> "IOResult a" in constructor application
The whole module Graphics_Utilities is rather Hugs-specific, and so
is the type IOResult. The definition of IOResult (it used to be
"data IOResult a = ...") has changed in the latest Hugs release, and,
as you could see, it is no longer polymorphic. Thus "IOResult a" is no
longer a well-formed type.
You can try to fix this in two ways. Either get hold of a somewhat
older version of Hugs, or you can try to patch the library.
The module Graphics_Utilities exports three functions: bracket,
bracket_, and safeTry. But only the two first are actually
used outside of the module. Fortunately, it seems as if the
Hugs module IO now provides compatible versions of bracket and
bracket_ (judging from the type signatures: I have not tried).
Thus you could try to either replace the old Graphics_Utilities.hs with
the following trivial version:
module Graphics_Utilities(module IO) where
import IO (bracket, bracket_)
or, even better, replace any "import Graphics_Utilities" in the rest
of the library with "import IO (bracket, bracket_)".
As far as I can tell, you only have to do the latter for GraphicsWindow
and GraphicsDC. In both cases, Graphics_Utilities are imported qualified
(the graphics library uses the names bracket and bracket_ itself for
other purposes), so you actually would have to import IO like this:
import qualified IO (bracket, bracket_) as Utils
I hope this helps.
/Henrik
--
Henrik Nilsson
Yale University
Department of Computer Science
nilsson@cs.yale.edu