[Haskell-beginners] how to install "import Foreign.C.Types( CFloat )" in Ubuntu

Daniel Fischer daniel.is.fischer at web.de
Tue Nov 24 09:00:37 EST 2009


Am Dienstag 24 November 2009 08:11:25 schrieb Zsolt Ero:
> I am trying to run a file, which works well on the university system,
> but I don't know what do I need to do to make it work on my home
> Ubuntu system.
>
> The particular line which makes the error is:
> import Foreign.C.Types( CFloat )
>
> And the error is:
> -----------------------------------------------------------
> LSystem.hs:130:4:
>     No instance for (ColorComponent CFloat)
>       arising from a use of `color' at LSystem.hs:130:4-26
>     Possible fix:
>       add an instance declaration for (ColorComponent CFloat)
>   .....
> -------------------------------------------------------------

The problem is not Foreign.C.Types, it's in your OpenGL lib.
Probably different versions at home and university.
Try adding

instance ColorComponent CFloat

to LSystem.hs

If that doesn't work, replacing (color x) with (color $ realToFrac x) in all pertinent 
places should make it work.

>
> If I write "import Foreign.C.Types" at the Prelude it says nothing. If
> I write "import Foreign.C.Types( CFloat )" at the Prelude, it says
> <interactive>:1:0: parse error on input `import'

Yes, the import at the ghci-prompt is restricted, you can only do
import Module
there, no import lists, no hiding, no import qualified M as P.

>
> What can it be?
>
> Cheers,
> Zsolt




More information about the Beginners mailing list