Skip to content

Instantly share code, notes, and snippets.

@evanrinehart
Last active June 3, 2017 06:31
Show Gist options
  • Save evanrinehart/688cdbb2dc8f4f86281d34de5d899e37 to your computer and use it in GitHub Desktop.
Save evanrinehart/688cdbb2dc8f4f86281d34de5d899e37 to your computer and use it in GitHub Desktop.
withShader :: ShType -> Src -> (GLuint -> IO (Either String a)) -> IO (Either String a)
withShader ty src action = mask $ \restore -> do
eithv <- loadShader ty src
case eithv of
Left err -> return (Left err)
Right v -> restore (action v) `finally` deleteShader v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment