Skip to content

Instantly share code, notes, and snippets.

@norm2782
Created July 15, 2011 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norm2782/1084844 to your computer and use it in GitHub Desktop.
Save norm2782/1084844 to your computer and use it in GitHub Desktop.
I have a function
GIT_EXTERN(int) git_repository_open(git_repository **repository, const char *path);
Return int is a possible error code. Actual value I'm interested in is **repository
Haskell code:
openRepo :: String -> IO (Either GitError Repository)
openRepo path = do
let repo = nullPtr
pstr <- newCString path
res <- {#call git_repository_open#} repo pstr
return $ case res of
0 -> Right $ Repository repo
n -> Left . toEnum . fromIntegral $ n
newtype Repository = Repository { unRepository :: Ptr () }
This is not going too well:
Assertion failed: (repo_out && path), function git_repository_open, file repository.c, line 347.
What's going wrong here?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment