我有以下代码:
module Test
data Nat' = S' Nat' | Z'
Num Nat' where
x * y = ?hole
x + y = ?hole
fromInteger x = if x < 1 then Z' else S' (fromInteger (x - 1))
我收到关于最后一行的错误消息:
Test.idr:6:5:
Prelude.Interfaces.Test.Nat' implementation of Prelude.Interfaces.Num, method fromInteger is
possibly not total due to recursive path Prelude.Interfaces.Test.Nat' implementation of
Prelude.Interfaces.Num, method fromInteger --> Prelude.Interfaces.Test.Nat' implementation of
Prelude.Interfaces.Num, method fromInteger
该函数应始终给出结果,因为最终 fromInteger 的参数将变得足够小以选择第一种情况。但伊德里斯似乎并不理解这一点。这个功能有什么问题,我该如何解决这个错误?