Not in scope: type constructor or class

11,137

Solution 1

As duplode mentioned above, I've forgotten to import some modules. So, what all that should be done is add the following 4 lines to BoardMain.hs

import PegSolitaire
import Graphics.UI.Gtk.Board.TiledBoard
import Data.Maybe
import Control.Monad

GtkPegSolitaire.hs and PegSolitaire.hs are correct. The author of this game has been notified of this issue. Thanks duplode for helping us.

Solution 2

The definitions of your types are in PegSolitaire, but you do not import it in the main module. There, you have only imported GtkPegSolitaire and a handful of library modules. Imports are not transitive, so you need to add import PegSolitaire to the main module. (If imports were transitive, it would, for one, be impossible for library writers to keep modules hidden from the public API.)

Share:
11,137
duplex143
Author by

duplex143

Updated on June 20, 2022

Comments

  • duplex143
    duplex143 almost 2 years

    I've a Haskell code for a game where the complete one can be found here.

    The following is BoardMain.hs

    {-# Language MultiParamTypeClasses, FunctionalDependencies #-}
    
    import Control.Monad.Trans (liftIO)
    import Graphics.UI.Gtk
    import Graphics.UI.Gtk.Layout.BackgroundContainer
    import Graphics.UI.Gtk.Board.BoardLink
    import GtkPegSolitaire
    
    
    attemptDragStart :: Board Int Tile Peg -> (Int, Int) ->  IO Bool
    attemptDragStart _ _ = return True
    

    When I'm running this, I'm getting the following error

     BoardMain.hs:39:21: error:
        Not in scope: type constructor or class ‘Board’
    
    BoardMain.hs:39:31: error:
        Not in scope: type constructor or class ‘Tile’
    
    BoardMain.hs:39:36: error:
        Not in scope: type constructor or class ‘Peg’
    

    I know that I've made a small mistake. Any help is appreciated.

    GtkPegSolitaire.hs and PegSolitaire.hs can be found here