title: How to extract at runtime the AST or the bytecode or anything that uniquelly, deterministically and universally identifies a function* in Haskell?
body: <p>I have managed to do it in Python, since the interpreter provide the bytecodes, as shown below.
  From the bytecodes it was easy to apply a hashing function.</p>
  <pre><code>import dis
  from inspect import signature
  
  # Add signature.
  fargs = list(signature(f).parameters.keys())
  if not fargs:
      raise Exception(f&quot;Missing function input parameters.&quot;)
  clean = [fargs]
  
  # Clean line numbers.
  groups = [l for l in dis.Bytecode(f).dis().split(&quot;\n\n&quot;) if l]
  for group in groups:
      lines = [segment for segment in group.split(&quot; &quot;) if segment][1:]
      clean.append(lines)
  </code></pre>
  <p>How could I extract a similar kind of <em>deterministic</em> <em>universally</em> <em>unique</em> ¹ function identifier in Haskell?
  Are there built-in libraries or GHC extensions for that?</p>
  <p><code>1 -</code> <em>unique</em>, probabilistically speaking</p>
  <p><code>* -</code> A <em>function</em> not in the math sense, since the possibilities to check programatically the equivalence of programs are very limited. So I am only interested in what is possible and costless attainable, i.e., generate a unique identity for functions with the exact same code (or bytecode, to avoid formatting noise). In my specific use case, even the signatures and parameter names should match, but that is not relevant for the point here, which is about how to inspect Haskell code at runtime.</p>