title: 'Failed to load interface' error when loading compiled modules in ghci
body: <p>Hello Haskell community,</p>
  
  <p>I'm new to Haskell and ran into a problem when I tried to structure my first bigger project.</p>
  
  <p>Here's the minimal example of the problem (I'm using cabal to build).</p>
  
  <p>This is the directory structure of a simple module:</p>
  
  <pre><code>FooMod1
  |- FooMod1.cabal
  |- Setup.hs
  |- src
    |- FooMod1.hs
    |- FooMod1
      |- C1.hs
      |- T1.hs
  </code></pre>
  
  <p>The source for FooMod1.hs:</p>
  
  <pre><code>module FooMod1 (
      C1(..) ,
      T1(..) ,
  ) where 
  
  import FooMod1.C1
  import FooMod1.T1
  </code></pre>
  
  <p>The source for C1.hs:</p>
  
  <pre><code>module FooMod1.C1 (
      C1(..)
  ) where
  
  class C1 a where
      c1FooFun :: a -&gt; IO ()
  </code></pre>
  
  <p>The source for T1.hs:</p>
  
  <pre><code>module FooMod1.T1 (
      T1(..)
  ) where
  
  import FooMod1.C1
  
  data T1 = T1 deriving(Show)
  
  instance C1 T1 where
      c1FooFun T1 = putStrLn "c1FooFun from T1"
  </code></pre>
  
  <p>The source for the cabal file:</p>
  
  <pre><code>Name:                      FooMod1
  Version:                   0.0.1
  Cabal-version:             &gt;=1.10
  Build-type:                Simple
  
  library 
    build-depends:           base &gt;= 4 &amp;&amp; &lt; 5
    if impl(ghc &gt;= 7.0.0)
       default-language:     Haskell2010
    ghc-options:             -Wall
    exposed-modules:         FooMod1
  
    ghc-options:             -Wall -rtsopts
    hs-source-dirs:          src, src/FooMod1
    default-language:        Haskell2010
  </code></pre>
  
  <p>and the Setup.hs:</p>
  
  <pre><code>module Main where
  
  import Distribution.Simple
  
  main = defaultMain
  </code></pre>
  
  <p>I can do </p>
  
  <pre><code>cabal configure
  cabal build
  cabal install
  </code></pre>
  
  <p>without any problem. When I start ghci and</p>
  
  <pre><code>import FooMod1
  </code></pre>
  
  <p>it loads the module and I can see the data constructors.
  But when I try to get the type of a function for example </p>
  
  <pre><code>:t c1FooFun
  </code></pre>
  
  <p>or construct a value I get:</p>
  
  <pre><code>Failed to load interface for `FooMod1.C1'
  There are files missing in the `FooMod1-0.0.1' package,
  try running 'ghc-pkg check'.
  Use -v to see a list of the files searched for.
  In the expression: c1FooFun
  </code></pre>
  
  <p>'ghc-pkg check' reveals nothing.</p>
  
  <p>What am I missing? I looked it up in the Haskell 2010 Standard (<a href="http://www.haskell.org/onlinereport/haskell2010/haskellch5.html">http://www.haskell.org/onlinereport/haskell2010/haskellch5.html</a>) and i can't find the error. So my questions are</p>
  
  <p>1) Why am I getting this error?</p>
  
  <p>2) Is structuring a hierarchical modules like that good practice? (assume considerably larger programs)</p>
  
  <p>Many thanks in advance!</p>
  
  <p>Jules  </p>