
Hi, I created a small Genetic Algorithm program, replicating this work ("Statistical mechanics of program systems" - JP Neirotti, N. Caticha, Journal of Physics A Math and Gen) made in Lisp. When a restricted the problem just for one type, the Haskell program worked perfectly with much less lines and a lot faster than the Lisp program. The problem was when I tried to generalize to polymorphic types. I'm using this datatype to represent a program: data Tree a = Bin (String, (a -> a -> a)) (Tree a) (Tree a) | Un (String, (a -> a)) (Tree a) | V And can convert a Tree to a function with: treeToFunc :: Tree a -> a -> a treeToFunc (Bin f l r) = (snd f) <$> treeToFunc l <*> treeToFunc r treeToFunc (Un f u) = (snd f).(treeToFunc u) treeToFunc V = id I already create another datatype to represent a polymorphic program (using GADT or existentials), but doesn't see a way to convert this kind of tree to a function. Anyone has any idea? Thanks, Edgar