
Pasqualino 'Titto' Assini wrote:
Is there any fundamental reasons why Haskell functions/closures cannot be serialised?
I believe that this is precisely what the distributed version of GHC used to do.
Most languages, even Java, have a reflection capability to dynamically inspect an object. It is surprising that Haskell doesn't offer it.
Inspecting functions is not referentially transparent. In Haskell, function equality is extensional, i.e. two functions are equal when their results are equal on all arguments. Intensional equality would mean that functions are equal when they have the same representation. If you allow a function serialize :: (Int -> Int) -> String that can give different results on intensionally different functions, you may not expect equations like f (*3) == f (\n -> n+n+n) to hold anymore (because f might inspect its argument). Also, having "serialize" somehow check whether intensionally different arguments are extensionally the same and should have a unique serialization is no option because this problem is undecidable. Regards, apfelmus