Skip to content

Instantly share code, notes, and snippets.

@stelleg
Created July 29, 2018 15:56
Show Gist options
  • Save stelleg/241f0671a1d7cb413c07f0d9ec9a32bb to your computer and use it in GitHub Desktop.
Save stelleg/241f0671a1d7cb413c07f0d9ec9a32bb to your computer and use it in GitHub Desktop.
alpha-equivalence example
import Foreign.Ptr
import Foreign.Storable
import Foreign.Marshal.Array
{-@ type PtrLen a n = {v:Ptr a | plen v = n && 0 <= pbase v && 0 <= plen v} @-}
{-@ withArray :: Storable a => x:[a] -> (PtrLen a (len x) -> IO b) -> IO b @-}
{-@ withConstArray :: Storable a => a -> n:Nat -> (PtrLen a n -> IO b) -> IO b @-}
withConstArray x n = withArray (replicate n x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment