Skip to content

Instantly share code, notes, and snippets.

View jmcarthur's full-sized avatar

Jake McArthur jmcarthur

  • Jersey City, NJ, USA
View GitHub Profile
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
ncInq :: NCID -> IO (Int, Int, Int, Int)
ncInq ncid =
alloca $ \ndims_ptr ->
alloca $ \nvars_ptr ->
alloca $ \natts_ptr ->
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
@jmcarthur
jmcarthur / thunk-fail
Created September 28, 2013 18:56
Trying to get familiar with Rust's pointers and closures by implementing a thunk data type
enum ThunkData<T> {
Val (T),
Fun (~fn() -> T)
}
struct Thunk<T> {
thunkData: ThunkData<T>
}
impl<T : Clone> Thunk<T> {
@jmcarthur
jmcarthur / liftetime
Created September 28, 2013 19:53
A little experiment that has led to a question about lifetimes in Rust.
struct Thunk<'a, T> {
f : ~fn() -> & 'a T
}
Here is a section of a message I sent to Francois-Regis Sinot regarding his paper
Complete Laziness: A Natural Semantics
http://www.lsv.ens-cachan.fr/Publis/PAPERS/PDF/sinot-wrs07.pdf
---------------
I have simplified the problem down to this expression:
(\z. (\x. \y. x) (\w. z)) I I I
Where I is the identity function. Preprocessing, this translates to (with some manual simplifications):