Skip to content

Instantly share code, notes, and snippets.

View acowley's full-sized avatar

Anthony Cowley acowley

  • Philadelphia, PA, USA
View GitHub Profile
{-# LANGUAGE ScopedTypeVariables #-}
module Rendering.CLGLBuffer where
import Control.Parallel.CLUtil
import Foreign.Ptr (nullPtr)
import Foreign.Storable (Storable(sizeOf))
import Graphics.GLUtil.BufferObjects
import Graphics.Rendering.OpenGL (deleteObjectName, BufferObject, BufferTarget(..))
import Rendering.CLGLInterop
data CLGLBuffer a = CLGLBuffer { asVBO :: BufferObject

Keybase proof

I hereby claim:

  • I am acowley on github.
  • I am acowley (https://keybase.io/acowley) on keybase.
  • I have a public key whose fingerprint is 42A1 A9F7 9A8F 7310 4DE7 6BED A23C 1208 D50A 574B

To claim this, I am signing this object:

@acowley
acowley / gist:6769022
Created September 30, 2013 19:39
Image indexing for 2D or 3D images of various color depths.
{-# LANGUAGE TypeFamilies, DataKinds, ScopedTypeVariables,
MultiParamTypeClasses, TemplateHaskell, GADTs,
FlexibleContexts #-}
import Data.Proxy
import Data.Singletons
import qualified Data.Foldable as F
import Linear (V2(..), V3(..))
data Mat (d::Dimension) (c::Channel) e
@acowley
acowley / mdedetrichModel.hs
Created July 2, 2013 01:48
Example of vinyl subtyping.
{-# LANGUAGE DataKinds, FlexibleContexts, TypeOperators #-}
import Data.Vinyl
type Model = "model" ::: String
model :: Model
model = Field
type Car = PlainRec ["company":::String, Model, "year":::Int]
@acowley
acowley / StorableBinary.hs
Created June 7, 2013 21:59
Demonstrate building a ByteString from heterogenous Storable types.
{-# LANGUAGE ScopedTypeVariables #-}
import Data.Binary.Builder
import Data.Binary.Builder.Internal
import Foreign.Ptr (castPtr)
import Foreign.Storable (Storable(sizeOf,poke))
-- For testing
import Linear
import Data.ByteString.Lazy (ByteString)
import Data.Monoid ((<>))
@acowley
acowley / VectorByteString.hs
Created June 7, 2013 16:21
Data.Vector.Storable and Data.ByteString
{-# LANGUAGE ScopedTypeVariables #-}
import Control.Monad ((>=>))
import Data.ByteString (ByteString)
import qualified Data.ByteString as B
import qualified Data.ByteString.Unsafe as B
import Data.Vector.Storable (Vector)
import qualified Data.Vector.Storable as V
import Foreign.C.String (CStringLen)
import Foreign.Ptr (castPtr)
import Foreign.Storable (Storable(sizeOf))
@acowley
acowley / gist:2417401
Created April 18, 2012 23:43
cabal-test with internal modules
name: cabal-test-test
version: 0.1.0.0
build-type: Simple
cabal-version: >=1.8
-- Library source in "src/lib", Internal module in "src/misc"
library
exposed-modules: MyLib.Foo
other-modules: MyLib.Internal.Bar
hs-source-dirs: src/lib, src/misc
@acowley
acowley / gist:2362200
Created April 11, 2012 20:23
Proof of Nichomacus's theorem in Coq.
(* Ported from Dan Peebles's proof at: https://gist.github.com/2356060 *)
Module SquaredTriangular.
Require Import Arith.
Definition N := nat.
(* Sigma notation for expressing sums. *)
Fixpoint Σ (x : N) (f : N -> N) : N :=
match x with
| 0 => 0
@acowley
acowley / CLGLInterop.hs
Created March 23, 2012 17:07
Example of setting up OpenCL to use an OpenGL context. Uses the CLUtil library.
{-# LANGUAGE ForeignFunctionInterface #-}
module Renderer.CLGLInterop (initFromGL) where
import Control.Parallel.CLUtil
import Foreign.Ptr (nullPtr, Ptr)
foreign import ccall "CGLGetCurrentContext"
cGLGetCurrentContext :: IO (Ptr ())
foreign import ccall "CGLGetShareGroup"
cGLGetShareGroup :: Ptr () -> IO (Ptr ())
@acowley
acowley / PipelineMutation.hs
Created May 20, 2011 05:06
Fused in-place updates of mutable values
{-# OPTIONS -O #-}
-- Perform in-place updates on mutable data.
import Control.Applicative
import Control.Monad
import Data.IORef
import Data.Monoid
import Debug.Trace
import System.IO.Unsafe
-- Presumably we can duplicate the values we want to mutate. Here, we