-3

Can I define a data type named HundredBytes in Haskell such that a value of TwoBytes will always have 100 bytes?

Thanks!

user962815
  • 155
  • 1
  • 5

1 Answers1

1

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))))
dfeuer
  • 48,079
  • 5
  • 63
  • 167