Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not in scope: type constructor or class

Tags:

haskell

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

like image 501
duplex143 Avatar asked Apr 11 '17 11:04

duplex143


2 Answers

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.)

like image 116
2 revs Avatar answered Nov 02 '22 02:11

2 revs


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.

like image 3
duplex143 Avatar answered Nov 02 '22 02:11

duplex143