byteverse / contiguous

Typeclass for array types
Other
19 stars 9 forks source link

'convert' should be 'map id' #9

Closed chessai closed 5 years ago

chessai commented 5 years ago

the relevant types:

map :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => (b -> c) -> arr1 b -> arr2 c

convert :: (Contiguous arr1, Element arr1 b, Contiguous arr2, Element arr2 c) => arr1 b -> arr2 b

convert actually has the exact same implementation as map, except that b unifies with c in the case of the former.

So, we should change the implementation of convert a = runST $ do ... to convert a = map id a.