title: Type erasure in Haskell?
body: <p>I was reading a <a href="https://www.seas.upenn.edu/%7Ecis194/spring15/fall14/lectures/04-poly.html" rel="noreferrer">lecture note</a> on Haskell when I came across this paragraph:</p>
  <blockquote>
  <p>This “not caring” is what the “parametric” in parametric polymorphism means. All Haskell functions must be parametric in their type parameters; the functions must not care or make decisions based on the choices for these parameters. A function can't do one thing when a is Int and a different thing when a is Bool. Haskell simply provides no facility for writing such an operation. This property of a langauge is called parametricity.</p>
  <p>There are many deep and profound consequences of parametricity. One consequence is something called type erasure. Because a running Haskell program can never make decisions based on type information, all the type information can be dropped during compilation. Despite how important types are when writing Haskell code, they are completely irrelevant when running Haskell code. This property gives Haskell a huge speed boost when compared to other languages, such as Python, that need to keep types around at runtime. (Type erasure is not the only thing that makes Haskell faster, but Haskell is sometimes clocked at 20x faster than Python.)</p>
  </blockquote>
  <p>What I don't understand is how are &quot;all Haskell functions&quot; parametric? Aren't types explicit/static in Haskell? Also I don't really understand how type erasure improves <strike>compiling time</strike> runtime?</p>
  <p>Sorry if these questions are really basic, I'm new to Haskell.</p>
  <p>EDIT:</p>
  <p>One more question: why does the author say that &quot;Despite how important types are when writing Haskell code, they are completely irrelevant when running Haskell code&quot;?</p>