packages feed

ivory-examples-0.1.0.5: examples/ConstPtrRef.hs

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}

module ConstPtrRef where

import           Control.Applicative (pure)
import           Ivory.Language

test :: Def ('[ConstRef s ('Stored (Ptr 'Global ('Stored Uint8)))] ':-> ())
test = proc "ConstPtrRef_test" $ \refptr -> body $ do
  ptr <- deref refptr
  withRef ptr
    (\ref -> do
      val <- deref ref
      store ref $ val + 1)
    (pure ())

cmodule :: Module
cmodule = package "ConstPtrRef" $ incl test