arrayTest :: Def ('[] :-> Uint32)
arrayTest = proc "arrayTest" $ ensures (==? 6) $ body $ do
  -- Allocate a 4 element array with zeros: [0, 0, 0, 0]
  (array :: Ref (Stack cs) (Array 4 (Stored Uint32))) <- local $ iarray $ replicate 4 $ ival 0

  -- Iterate over the array making it: [0, 1, 2, 3]
  arrayMap $ \ i -> store (array ! i) $ safeCast i  --XXX Having both this loop and the loop below gives ACL2 troubles.

  -- Create a reference to sum the elements in the array.
  sum <- local $ ival (0 :: Uint32)

  -- Loop across the array summing the elements.
  arrayMap $ \ i ->  do
    n <- deref sum
    m <- deref $ array ! i
    store sum $ n + m

  -- Return the computed sum.
  deref sum >>= ret
arrayTest :: Def ('[] :-> Uint32)
arrayTest = proc "arrayTest" $ ensures (==? 6) $ body $ do
  -- Allocate a 4 element array with zeros: [0, 0, 0, 0]
  (array :: Ref (Stack cs) (Array 4 (Stored Uint32))) <- local $ iarray $ replicate 4 $ ival 0

  -- Iterate over the array making it: [0, 1, 2, 3]
  arrayMap $ \ i -> store (array ! i) $ safeCast i  --XXX Having both this loop and the loop below gives ACL2 troubles.

  -- Create a reference to sum the elements in the array.
  sum <- local $ ival (0 :: Uint32)

  -- Loop across the array summing the elements.
  arrayMap $ \ i ->  do
    n <- deref sum
    m <- deref $ array ! i
    store sum $ n + m

  -- Return the computed sum.
  deref sum >>= ret
arrayTest = proc "arrayTest" $ ensures (==? 6) $ body $ do
  -- Allocate a 4 element array with zeros: [0, 0, 0, 0]
  (array :: Ref (Stack cs) (Array 4 (Stored Uint32))) <- local $ iarray $ replicate 4 $ ival 0

  -- Iterate over the array making it: [0, 1, 2, 3]
  arrayMap $ \ i -> store (array ! i) $ safeCast i  --XXX Having both this loop and the loop below gives ACL2 troubles.

  -- Create a reference to sum the elements in the array.
  sum <- local $ ival (0 :: Uint32)

  -- Loop across the array summing the elements.
  arrayMap $ \ i ->  do
    n <- deref sum
    m <- deref $ array ! i
    store sum $ n + m

  -- Return the computed sum.
  deref sum >>= ret