-- | Helper for @load*Program*@ variants.
loadShaderProgramWith' :: (ShaderType -> a -> IO Shader)
                       -> [(ShaderType, a)] -> (Program -> IO ())
                       -> IO ShaderProgram
loadShaderProgramWith' load sources m =
  do p <- mapM (uncurry load) sources >>= flip linkShaderProgramWith m
     throwError
     (attrs,unis) <- getActives p
     return $ ShaderProgram (fromList attrs) (fromList unis) p

-- |Load a 'ShaderProgram' from a list of individual shader program
-- files. The active attributes and uniforms in the linked program are
-- recorded in the 'ShaderProgram'
loadShaderProgramWith' :: (ShaderType -> a -> IO Shader)
                       -> [(ShaderType, a)] -> (Program -> IO ())
                       -> IO ShaderProgram
loadShaderProgramWith' load sources m =
  do p <- mapM (uncurry load) sources >>= flip linkShaderProgramWith m
     throwError
     (attrs,unis) <- getActives p
     return $ ShaderProgram (fromList attrs) (fromList unis) p

-- |Load a 'ShaderProgram' from a list of individual shader program
-- files. The active attributes and uniforms in the linked program are
-- recorded in the 'ShaderProgram'
loadShaderProgramWith' load sources m =
  do p <- mapM (uncurry load) sources >>= flip linkShaderProgramWith m
     throwError
     (attrs,unis) <- getActives p
     return $ ShaderProgram (fromList attrs) (fromList unis) p

-- |Load a 'ShaderProgram' from a list of individual shader program
-- files. The active attributes and uniforms in the linked program are
-- recorded in the 'ShaderProgram'