Add new PrimArray constructor
This commit is contained in:
parent
ad25af6e3f
commit
a95f38202c
|
@ -26,6 +26,13 @@ arrayDataSet : Nat -> a -> ArrayData a -> IO ()
|
|||
arrayDataSet n x arr = fromPrim $ prim__arraySet arr (cast n) x
|
||||
|
||||
|
||||
export
|
||||
unsafeFromIns : Nat -> List (Nat, a) -> PrimArray a
|
||||
unsafeFromIns size ins = unsafePerformIO $ do
|
||||
arr <- newArrayData size (believe_me ())
|
||||
for_ ins $ \(i,x) => arrayDataSet i x arr
|
||||
pure $ MkPrimArray size arr
|
||||
|
||||
export
|
||||
create : Nat -> (Nat -> a) -> PrimArray a
|
||||
create size f = unsafePerformIO $ do
|
||||
|
@ -40,7 +47,6 @@ create size f = unsafePerformIO $ do
|
|||
addToArray (S loc) n arr
|
||||
|
||||
|
||||
|
||||
export
|
||||
unsafeIndex : Nat -> PrimArray a -> a
|
||||
unsafeIndex n arr = unsafePerformIO $ arrayDataGet n $ content arr
|
||||
|
|
Loading…
Reference in a new issue