Sunday, January 7, 2018

Cabal install of wxHaskell CBool Error

So recently, I have been trying to dive back into programming with a little more oomph than a one-off project. I figured setting up a GUI along side would help keep me motivated. Now my current computer is an older Mac Book Pro because it is one of the few laptops in the house with a working battery. After diving around a large amount of fluff without any real substance, I decided going with wxHaskell would be the better choice. So I made sure wx was installed and did a cabal install wx, and wouldn't you know it that it failed.

src/haskell/Graphics/UI/WXCore/WxcTypes.hs:752:20: error:
    Ambiguous occurrence ‘CBool’
    It could refer to either ‘Foreign.C.CBool’,
                             imported from ‘Foreign.C’ at src/haskell/Graphics/UI/WXCore/WxcTypes.hs:126:1-16
                             (and originally defined in ‘Foreign.C.Types’)
                          or ‘Graphics.UI.WXCore.WxcTypes.CBool’,
                             defined at src/haskell/Graphics/UI/WXCore/WxcTypes.hs:750:1
    |
752 | toCBool :: Bool -> CBool
    |                    ^^^^^

src/haskell/Graphics/UI/WXCore/WxcTypes.hs:755:22: error:
    Ambiguous occurrence ‘CBool’
    It could refer to either ‘Foreign.C.CBool’,
                             imported from ‘Foreign.C’ at src/haskell/Graphics/UI/WXCore/WxcTypes.hs:126:1-16
                             (and originally defined in ‘Foreign.C.Types’)
                          or ‘Graphics.UI.WXCore.WxcTypes.CBool’,
                             defined at src/haskell/Graphics/UI/WXCore/WxcTypes.hs:750:1
    |
755 | withBoolResult :: IO CBool -> IO Bool
    |                      ^^^^^

src/haskell/Graphics/UI/WXCore/WxcTypes.hs:760:14: error:
    Ambiguous occurrence ‘CBool’
    It could refer to either ‘Foreign.C.CBool’,
                             imported from ‘Foreign.C’ at src/haskell/Graphics/UI/WXCore/WxcTypes.hs:126:1-16
                             (and originally defined in ‘Foreign.C.Types’)
                          or ‘Graphics.UI.WXCore.WxcTypes.CBool’,
                             defined at src/haskell/Graphics/UI/WXCore/WxcTypes.hs:750:1
    |
760 | fromCBool :: CBool -> Bool
    |              ^^^^^

src/haskell/Graphics/UI/WXCore/WxcTypes.hs:763:55: error:
    Ambiguous occurrence ‘CBool’
    It could refer to either ‘Foreign.C.CBool’,
                             imported from ‘Foreign.C’ at src/haskell/Graphics/UI/WXCore/WxcTypes.hs:126:1-16
                             (and originally defined in ‘Foreign.C.Types’)
                          or ‘Graphics.UI.WXCore.WxcTypes.CBool’,
                             defined at src/haskell/Graphics/UI/WXCore/WxcTypes.hs:750:1
    |
763 | foreign import ccall "intToBool" intToCBool :: Int -> CBool
    |                                                       ^^^^^

src/haskell/Graphics/UI/WXCore/WxcTypes.hs:764:48: error:
    Ambiguous occurrence ‘CBool’
    It could refer to either ‘Foreign.C.CBool’,
                             imported from ‘Foreign.C’ at src/haskell/Graphics/UI/WXCore/WxcTypes.hs:126:1-16
                             (and originally defined in ‘Foreign.C.Types’)
                          or ‘Graphics.UI.WXCore.WxcTypes.CBool’,
                             defined at src/haskell/Graphics/UI/WXCore/WxcTypes.hs:750:1
    |
764 | foreign import ccall "boolToInt" cboolToInt :: CBool -> Int
    |                                                ^^^^^
cabal: Leaving directory '/var/folders/8_/gbh6jvpj5dng4lmty_f9bjwh0000gn/T/cabal-tmp-50540/wxcore-0.92.3.0'
cabal: Error: some packages failed to install:
wx-0.92.3.0-GsmnFZQfuQrJCt8TV3hj5w depends on wx-0.92.3.0 which failed to
install.
wxcore-0.92.3.0-Cn2phmaLu563t5S6tEBzjw failed during the building phase. The
exception was:
ExitFailure 1

So with that big mess, it was time to hunt for what to do. With any luck this will be fixed soon because I generally have very little idea of what I'm doing. So the first step was to see if there was an alternative without manual intervention. Nope. So, I downloaded the package that was having the problem.

https://hackage.haskell.org/package/wxcore

Then we extract and open up src/haskell/Graphics/UI/WXCore/WxcTypes.hs and edit line 127 to

import Foreign.C hiding (CBool)

Save the file, open up a terminal. Navigate to the wxcore-0.92.3.0 folder and run

cabal install

After it hopefully succeeds, which it did for me, just simply

cabal install wx

I hope this helps anyone that needs and that the need doesn't last too long. I came across someone mentioning this fix on Stack overflow I think, but I can't find the link to it and don't plan to search too hard for it.


Tag Cloud

.NET (1) A+ (2) addon (6) Android (4) anonymous functions (5) application (10) arduino (1) artificial intelligence (2) bash (4) c (7) camera (1) certifications (4) cobol (1) comptia (4) computing (2) css (2) customize (16) encryption (2) error (19) exploit (17) ftp (3) funny (2) gadget (3) games (2) Gtk (1) GUI (5) hardware (7) haskell (15) help (8) HTML (6) irc (2) java (5) javascript (21) Linux (20) Mac (5) malware (2) math (8) network (9) objects (2) OCaml (1) perl (4) php (9) plugin (7) programming (42) python (24) radio (1) regex (3) security (25) sound (1) speakers (1) ssh (3) story (1) Techs from the Crypt (2) telnet (2) tools (15) troubleshooting (5) Ubuntu (4) Unix (4) virtualization (1) web design (14) Windows (8) wx (2)