Type variable to be unified occurs in type

前端 未结 2 1684
眼角桃花
眼角桃花 2021-01-22 13:25

I have a function to reconstruct a tree from 2 lists. I return a list on all branches, but I am getting an error that I don\'t understand. But I assume it has to do with the ret

2条回答
  •  遥遥无期
    2021-01-22 13:51

    1. Ionut gave a comprehensive explanation of how type unification works, so here is a hint:

      [preoH, recon (preoLST@preoRST, inoLST@inoRST)]
      

      The first element has type 'a and the second element has type 'a list.

      [recon (preoLST, inoLST), preoH, recon (preoRST, inoRST)]
      

      The second element has type 'a and the first and third element have type 'a list.

    2. When you check lists for being empty, consider using null preoT, or handle the case using pattern matching.

提交回复
热议问题