Can I define a data type named HundredBytes in Haskell such that a value of TwoBytes will always have 100 bytes?
Thanks!
Can I define a data type named HundredBytes in Haskell such that a value of TwoBytes will always have 100 bytes?
Thanks!
Haskell has no concept of byte, which is generally a good thing—it's almost always more useful to think about the width of a number in bits than in bytes, especially since implementations are allowed to use tag bits. If you want something with 100 Word8
values, you can do this:
data Two a = Two a a
data Five a = Five a a a a a
newtype Hundred = Hundred (Five (Five (Two (Two Word8))))