File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ "use strict" ;
2+
3+ exports . peekSTArray = function ( xs ) {
4+ return function ( i ) {
5+ return function ( ) {
6+ return xs [ i ] ;
7+ } ;
8+ } ;
9+ } ;
10+
11+ exports . pokeSTArray = function ( xs ) {
12+ return function ( i ) {
13+ return function ( a ) {
14+ return function ( ) {
15+ xs [ i ] = a ;
16+ return { } ;
17+ } ;
18+ } ;
19+ } ;
20+ } ;
Original file line number Diff line number Diff line change 1+ -- | Partial functions for working with mutable arrays using the `ST` effect.
2+ -- |
3+ -- | This module is particularly helpful when performance is very important.
4+
5+ module Data.Array.ST.Partial
6+ ( peekSTArray
7+ , pokeSTArray
8+ ) where
9+
10+ import Control.Monad.Eff (Eff )
11+ import Control.Monad.ST (ST )
12+ import Data.Array.ST (STArray )
13+ import Data.Unit (Unit )
14+
15+ -- | Read the value at the specified index in a mutable array.
16+ foreign import peekSTArray
17+ :: forall a h r
18+ . Partial
19+ => STArray h a
20+ -> Int
21+ -> Eff (st :: ST h | r ) a
22+
23+ -- | Change the value at the specified index in a mutable array.
24+ foreign import pokeSTArray
25+ :: forall a h r
26+ . Partial
27+ => STArray h a
28+ -> Int
29+ -> a
30+ -> Eff (st :: ST h | r ) Unit
You can’t perform that action at this time.
0 commit comments