module test2 import StdArray, StdEnum Start = times m1 m2 where m1 :: *{{#Int}} m1 = {{3,2},{1,1}} m2 = {{2,3},{4,5}} SIZE = 2 times :: *{{#Int}} {{#Int}} -> *{{#Int}} times m1 m2 = updateInPlace m1 rowUpdate SIZE where rowUpdate :: *{#Int} Int -> *{#Int} rowUpdate row i = updateInPlace row (\v j = v * m2.[i,j]) SIZE // updates array first parameter with a function taking its value at p and p itself updateInPlace :: *(a e) (e Int -> e) Int -> *(a e) | Array a e updateInPlace arr1 f maxPos = updateLoop_ arr1 f 0 maxPos where updateLoop_ :: *(a e) (e Int -> e) Int Int -> *(a e) | Array a e updateLoop_ arr1 f pos maxPos | pos == maxPos = arr1 # (v, arr1) = arr1![pos] = {(updateLoop_ arr1 f (pos+1) maxPos) & [pos] = f v pos}