Unable to load module into ghci

i have a file called model.hs with it’s content as

module Model (Foo) where

data Foo = Yellow | Red | Blue deriving Show

I have another file called sim.hs where I am trying to import Foo. The content of this file is

module Sim where

import Model.Foo

But this throws an error Could not find module Model.Foo. What am I doing wrong here?

Foo is a type that is defined in the module Model. In Haskell you can’t import types or functions directly like that. You can import the entire module: import Model or you can import specific functions/types from a module with the syntax: import Model (Foo). Here is the section of the Haskell2010 report that describes all possible ways of importing things. Maybe the most useful part is this table with examples:

Import declaration Names brought into scope
import A x, y, A.x, A.y
import A() (nothing)
import A(x) x, A.x
import qualified A A.x, A.y
import qualified A() (nothing)
import qualified A(x) A.x
import A hiding () x, y, A.x, A.y
import A hiding (x) y, A.y
import qualified A hiding () A.x, A.y
import qualified A hiding (x) A.y
import A as B x, y, B.x, B.y
import A as B(x) x, B.x
import qualified A as B B.x, B.y

In your case Model can be substituted for A or B, and Foo can be substituted for x or y.