Search code examples
haskellheist

Why am I getting an EitherT type error?


When I try loading my Heist (0.11) templates with this function:

load :: MonadIO n => FilePath -> [(Text, Splice n)] -> IO (HeistState n)
load baseDir splices = do
    tmap <- runEitherT  $ do
        templates <- loadTemplates baseDir
        let hc = HeistConfig [] defaultLoadTimeSplices splices [] templates
        initHeist hc
    either (error . concat) return tmap

I get this error:

Couldn't match expected type `EitherT e0 m0 t0'
            with actual type `either-3.1:Control.Monad.Trans.Either.EitherT
                                [String] IO Heist.TemplateRepo'
In the return type of a call of `loadTemplates'
In a stmt of a 'do' block: templates <- loadTemplates baseDir
In the second argument of `($)', namely
  `do { templates <- loadTemplates baseDir;
        let hc
              = HeistConfig [] defaultLoadTimeSplices splices [] templates;
        initHeist hc }'

To me, loadTemplate seems to be returning the expected type, except with the type parameters filled in with concrete types. What am I missing?


Solution

  • This happens in cases where there are multiple versions of the same package installed. Use ghc-pkg to remove all but one version of the either package, then reinstall and try it again.

    I've been puzzled by this time and time again. When the types are right and you start to think it's a GHC bug, check for duplicate packages.