How to install Common module?

{-# LANGUAGE OverloadedStrings #-}

module Main (main) where

import qualified SDL
import qualified Common as C


main :: IO ()
main = C.withSDL $ C.withWindow "Lesson 01" (640, 480) $
  \w -> do

    screen <- SDL.getWindowSurface w
    -- pixelFormat <- SDL.surfaceFormat `applyToPointer` screen
    -- color <- SDL.mapRGB pixelFormat 0xFF 0xFF 0xFF
    SDL.surfaceFillRect screen Nothing (SDL.V4 maxBound maxBound maxBound maxBound)
    SDL.updateWindowSurface w

    SDL.delay 2000

    SDL.freeSurface screen

This is my source code,and when I try to run it in GHCI,I got an error

Main.hs:6:1: error:
    Could not find module ‘Common’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
6 | import qualified Common as C

so I attempted to use cabal to install this Common module,but got another error:

D:\CS\Haskell\test\haskell-stuff-master\sdl>cabal install Common
Resolving dependencies...
cabal.exe: Could not resolve dependencies:
[__0] unknown package: Common (user goal)
[__0] fail (backjumping, conflict set: Common)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: Common

How do I install this module with cabal?

There are modules (specified by the Haskell language) and there are packages (specified by the Cabal packaging system). A module in Haskell always corresponds to a single source file with the same name, while a package would be a collection of modules together with a *.cabal file that describes how to put them together. So, you cannot really install any module with Cabal — you would install a whole package of them.

It looks to me as though a file named Common.hs or Common.lhs should be found somewhere near the place you found the code you posted — maybe in the same package.

1 Like

I’ve found Common.hs,Kindaro.Thank you so much