-- | Registering gl storage for given pipeline
registerStorageInternal :: PipelineId -> GLStorage -> LambdaCubeEnv t -> IO StorageId
registerStorageInternal pid storage LambdaCubeEnv{..} = do
  let mkId n = StorageId {
          storageId = n
        , storageScheme = pid
        }
  atomicModifyIORef lambdaEnvStorages $ \(i, m) -> let i' = mkId i
    in ((i + 1, M.insert i' storage m), i')

-- | Remove and deallocate storage
registerStorageInternal :: PipelineId -> GLStorage -> LambdaCubeEnv t -> IO StorageId
registerStorageInternal pid storage LambdaCubeEnv{..} = do
  let mkId n = StorageId {
          storageId = n
        , storageScheme = pid
        }
  atomicModifyIORef lambdaEnvStorages $ \(i, m) -> let i' = mkId i
    in ((i + 1, M.insert i' storage m), i')

-- | Remove and deallocate storage
registerStorageInternal pid storage LambdaCubeEnv{..} = do
  let mkId n = StorageId {
          storageId = n
        , storageScheme = pid
        }
  atomicModifyIORef lambdaEnvStorages $ \(i, m) -> let i' = mkId i
    in ((i + 1, M.insert i' storage m), i')

-- | Remove and deallocate storage