为什么此程序在REPL中打印某种AST?

时间:2018-08-06 23:27:44

标签: idris

import Data.Nat.Views

total toBinary : Nat -> String
toBinary k with (halfRec k)
  toBinary Z | HalfRecZ = ""
  toBinary (n + n) | (HalfRecEven rec) = (toBinary n | rec) ++ "0"
  toBinary (S (n + n)) | (HalfRecOdd rec) = (toBinary n | rec) ++ "1"

当使用表达式toBinary 2在REPL中测试上述功能时,将打印以下内容。

prim__concat (with block in Exercises.toBinary 1
                                           (with block in with block in Data.Nat.Views.halfRec 0
                                                                                               (half 0)
                                                                                               (Access (\z, zLTy =>
                                                                                                          Prelude.WellFounded.sizeAccessible, acc Nat
                                                                                                                                                  2
                                                                                                                                                  (constructor of Prelude.WellFounded.Sized (\meth =>
                                                                                                                                                                                               meth))
                                                                                                                                                  1
                                                                                                                                                  z
                                                                                                                                                  (lteTransitive zLTy
                                                                                                                                                                 (LTESucc LTEZero))))))
         "0" : String

当我运行:exec toBinary 2时,会打印出"10"的预期结果。

任何人都可以解释发生了什么事吗?

0 个答案:

没有答案