Closed borsboom closed 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.
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.
@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).
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.
@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.
Fixed in 8185a1d, after much cleanup and refactoring.
Tested with lateset commit (c1368434b0e0cb2bebf1df70def0dddf472f3712)