Array.dcl 1.32 KB
Newer Older
1 2 3
definition module Data.Array

from StdArray import class Array
4
from StdOverloaded import class +++
Mart Lubbers's avatar
Mart Lubbers committed
5
from Data.Functor import class Functor
6
from Control.Applicative import class pure, class <*>, class Applicative
Mart Lubbers's avatar
Mart Lubbers committed
7
from Control.Monad import class Monad
8

9
mapArrSt :: !(.a -> .(*st -> *(.a, *st))) !*(arr .a) !*st -> *(!*(arr .a), !*st) | Array arr a
10 11

foldrArr :: !(a .b -> .b) !.b !.(arr a) -> .b | Array arr a
Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
12

Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
13
foldrArrWithKey :: !(Int a -> .(.b -> .b)) !.b !.(arr a) -> .b | Array arr a
Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
14

15
foldrUArr :: !(a -> .(.b -> .(*(arr a) -> *(.b, *(arr a))))) .b !*(arr a)
Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
16 17
          -> *(.b, *(arr a)) | Array arr a

18
foldrUArrWithKey :: !(Int a -> .(.b -> .(*(arr a) -> *(.b, *(arr a))))) .b !*(arr a)
Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
19
                 -> *(.b, *(arr a)) | Array arr a
Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
20 21 22

foldlArr :: !(.b a -> .b) !.b !.(arr a) -> .b | Array arr a

Jurriën Stutterheim's avatar
Jurriën Stutterheim committed
23 24 25
foldlArrWithKey :: !(Int .b -> .(a -> .b)) !.b !.(arr a) -> .b | Array arr a

reverseArr :: !.(arr a) -> .arr a | Array arr a
26 27 28 29 30 31 32 33

takeArr :: !Int !.(arr a) -> .arr a | Array arr a

mapArr :: !(a -> a) !(arr a) -> arr a | Array arr a

appendArr :: !(arr a) !(arr a) -> arr a | Array arr a

instance +++ (arr a) | Array arr a
Mart Lubbers's avatar
Mart Lubbers committed
34 35

instance Functor {}, {!}
36 37
instance pure {}
instance pure {!} where pure :: !a -> {!a}
38
instance <*> {}, {!}
Mart Lubbers's avatar
Mart Lubbers committed
39
instance Monad {}, {!}
Mart Lubbers's avatar
Mart Lubbers committed
40

41
reduceArray :: ((.a -> u:(b -> b)) -> .(b -> .(c -> .a))) (.a -> u:(b -> b)) b !.(d c) -> b | Array d c