Skip to content

Instantly share code, notes, and snippets.

@chrisdone
Created May 22, 2019 17:15
Show Gist options
  • Save chrisdone/067384de160dbb3cae89a09e2efe4a0d to your computer and use it in GitHub Desktop.
Save chrisdone/067384de160dbb3cae89a09e2efe4a0d to your computer and use it in GitHub Desktop.
Prana primops demo
{-# LANGUAGE MagicHash, UnboxedTuples #-}
-- | Test some of the ops for Array# and MutableArray#.
module ArrayTest where
import GHC.Exts
import GHC.Types (IO(..))
it :: IO (Char, Int, Char)
it =
IO
(\s ->
case newArray# 22# 'a' s of
(# s', array #) ->
case readArray# array 0# s' of
(# s'', ch #) ->
case unsafeFreezeArray# array s'' of
(# s''', arr #) ->
(# s'''
, ( ch
, I# (sizeofMutableArray# array)
, case indexArray# arr 1# of
(# x #) -> x)#))
[ BeginConStep (UnboxedTupleConId 1)
, BeginConStep
(DataConId
(TypeId {typeIdInt = 117})
(ConIndex {conIndexInt = 0}))
, BeginConStep
(DataConId
(TypeId {typeIdInt = 21})
(ConIndex {conIndexInt = 0}))
, LitStep (CharLit 'a')
, EndConStep
, BeginConStep
(DataConId
(TypeId {typeIdInt = 20})
(ConIndex {conIndexInt = 0}))
, LitStep (IntLit 22)
, EndConStep
, BeginConStep
(DataConId
(TypeId {typeIdInt = 21})
(ConIndex {conIndexInt = 0}))
, LitStep (CharLit 'a')
, EndConStep
, EndConStep
, EndConStep
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment