Skip to content

Instantly share code, notes, and snippets.

@carlohamalainen
Created September 2, 2011 04:09
Show Gist options
  • Save carlohamalainen/1187895 to your computer and use it in GitHub Desktop.
Save carlohamalainen/1187895 to your computer and use it in GitHub Desktop.
ncInq :: NCID -> IO (Int, Int, Int, Int)
ncInq ncid = do
alloca $ \ndims_ptr -> do
alloca $ \nvars_ptr -> do
alloca $ \natts_ptr -> do
alloca $ \unlimdimid_ptr -> do
status <- nc_inq ncid ndims_ptr nvars_ptr natts_ptr unlimdimid_ptr
ndims <- peek ndims_ptr
nvars <- peek nvars_ptr
natts <- peek natts_ptr
unlimdimid <- peek unlimdimid_ptr
return (fromEnum ndims, fromEnum nvars, fromEnum natts, fromEnum unlimdimid)
@jmcarthur
Copy link

@tonymorris:

That is not equivalent. alloca takes a function as a parameter. See my last fork for an example using ContT that looks more like your version, though.

@tonymorris
Copy link

Ah yeah duh@me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment