purescript-contrib/purescript-arraybuffer

typelevel dependency

jamesdbrock opened this issue · 2 comments

For moving this package to purescript-contrib, @thomashoneyman has requested that the package has no dependencies outside of purescript-contrib, and the purescript-typelevel package does not belong to purescript-contrib.

The BytesPerValue class with the dependency on purescript-typelevel was introduced in this redesign by @athanclark .

#23

Do you have any advice about this @jacereda @athanclark ? How would you approach this?

From purescript-typelevel we only use the toInt' method of the Nat class on types D1, D2, D4, and D8.

Here's one thing which I think we could do which I think would completely eliminate the need for purescript-typelevel.

We could replace the BytesPerValue typeclass with something like this:

class BytesPerType (a :: ArrayViewType) where
  byteSize :: (Proxy a) -> Int

instance bytesPerTypeInt8 :: BytesPerType Int8 where byteSize _ = 1
instance bytesPerTypeInt16 :: BytesPerType Int16 where byteSize _ = 2

Then we would also be able to remove the Nat type constraint on a lot of public API functions, which would be a win in my opinion.

Resolved in v11.0.0 .