jwiegley / gitlib

180 stars 56 forks source link

gitlib-libgit2 smoke test build failure #8

Closed borsboom closed 11 years ago

borsboom commented 11 years ago

Tested with lateset commit (c1368434b0e0cb2bebf1df70def0dddf472f3712)

Configuring gitlib-libgit2-1.0.1...
Building gitlib-libgit2-1.0.1...
Preprocessing library gitlib-libgit2-1.0.1...
In-place registering gitlib-libgit2-1.0.1...
Preprocessing test suite 'smoke' for gitlib-libgit2-1.0.1...
[1 of 1] Compiling Main             ( test/Smoke.hs, dist/build/smoke/smoke-tmp/Main.o )

test/Smoke.hs:24:27:
    Occurs check: cannot construct the infinite type:
      r0 = Git.CommitRepository (Git.Commit r0)
    arising from a use of `Git.smokeTestSpec'
    In the second argument of `hspecWith', namely
      `(Git.smokeTestSpec
          (\ path _ act -> Lg.withLgRepository path True True act))'
    In a stmt of a 'do' block:
      summary <- hspecWith
                   (defaultConfig {configVerbose = True})
                   (Git.smokeTestSpec
                      (\ path _ act -> Lg.withLgRepository path True True act))
    In the expression:
      do { summary <- hspecWith
                        (defaultConfig {configVerbose = True})
                        (Git.smokeTestSpec
                           (\ path _ act -> Lg.withLgRepository path True True act));
           when (summaryFailures summary > 0) $ exitFailure;
           return () }

test/Smoke.hs:24:27:
    Occurs check: cannot construct the infinite type:
      r0 = Git.TreeRepository (Git.Tree r0)
    arising from a use of `Git.smokeTestSpec'
    In the second argument of `hspecWith', namely
      `(Git.smokeTestSpec
          (\ path _ act -> Lg.withLgRepository path True True act))'
    In a stmt of a 'do' block:
      summary <- hspecWith
                   (defaultConfig {configVerbose = True})
                   (Git.smokeTestSpec
                      (\ path _ act -> Lg.withLgRepository path True True act))
    In the expression:
      do { summary <- hspecWith
                        (defaultConfig {configVerbose = True})
                        (Git.smokeTestSpec
                           (\ path _ act -> Lg.withLgRepository path True True act));
           when (summaryFailures summary > 0) $ exitFailure;
           return () }

test/Smoke.hs:25:28:
    The lambda expression `\ path _ act
                             -> Lg.withLgRepository path True True act'
    has three arguments,
    but its type `tagged-0.4.4:Data.Proxy.Proxy (r0 ())' has none
    In the first argument of `Git.smokeTestSpec', namely
      `(\ path _ act -> Lg.withLgRepository path True True act)'
    In the second argument of `hspecWith', namely
      `(Git.smokeTestSpec
          (\ path _ act -> Lg.withLgRepository path True True act))'
    In a stmt of a 'do' block:
      summary <- hspecWith
                   (defaultConfig {configVerbose = True})
                   (Git.smokeTestSpec
                      (\ path _ act -> Lg.withLgRepository path True True act))
Failed to install gitlib-libgit2-1.0.1
jwiegley commented 11 years ago

@snoyberg I've fixed this issue, but I'm running into a type error in Project.hs in the learning-site that has me mystified. Michael, can you pull the devel branch and try building it? You should see just the one error that I was seeing.

snoyberg commented 11 years ago

runRepository as type:

RepositoryFactory r m -> Context r -> r a -> m a

gitFactory has type:

type LgRepoFactoryIO = Git.RepositoryFactory (Lg.LgRepository IO) IO

But the third argument to runRepository does not live in Lg.LgRepository IO, but instead in Lg.LgRepository (YesodDB App App). The error message you get is in the wrong location (yay GHC!). So first step: generalize gitFactory to the right type:

gitFactory :: (Applicative m, MonadIO m, Failure Git.GitException m) => LgRepoFactory m
gitFactory = Lg.lgFactory

But that still doesn't solve the problem, because it seems that openGitRepo now constrains the repository to working in the IO monad, which wasn't there before. I'm getting a little lost in the gitlib changes at this point, but that's the root of the problem.

jwiegley commented 11 years ago

@snoyberg Hmm.. from looking at the Git history, openGitRepo was constraining IO before. Which commit did that change in?

I think I have a better solution for this anyway: Just use Lg.runLgRepository instead of the generic machinery (which at least no longer uses a type class).

snoyberg commented 11 years ago

It's here: https://github.com/fpco/fpco/commit/c9ed35abde5057921b8a959c52564cfb6576b5f7#L1L85

Previously, there was an IO action returning a repository. The IO action can be lifted into any MonadIO, and then the repository can be used in any monad.

In the new system, there's an IO action returning a repository factory. That action can be lifted. However, the repository factory itself is constrained to IO, and therefore can't work in other monads. In this case, that means we can't perform database actions.

jwiegley commented 11 years ago

@snoyberg Thanks for the clarification. I'm specializing now to Libgit2, but I would like to walk through this constraints stuff with you for when we want to generalize to GitHub and git+ssh.

jwiegley commented 11 years ago

Fixed in 8185a1d, after much cleanup and refactoring.