Coerce for constant time newtype lists

October 29, 2016

haskell has a coerce function. It’s pretty cool!

in the haskell wiki, it talks about how newtypes incur no runtime cost, but when you have an array of newtypes, a runtime cost will still happen in order to instantiate the array of newtypes. Basically, a linear operation of noops will occur. This can be avoided by using coerce.