In Idris, how do I hide something defined in Prelude?

笑着哭i 提交于 2019-12-01 00:43:12

问题


I want to define my own version of fib to play around with, but fib is exported by the Prelude. How do I hide the import from the Prelude? In Haskell I would write import Prelude hiding (fib), but that doesn't work in Idris.


回答1:


As this Idris mailing post suggests:

At the minute, all there is the (as yet undocumented) %hide directive, which makes a name inaccessible.

Here is an example:

%hide fib

fib : Nat -> Nat
fib Z = Z
fib (S Z) = S Z
fib (S (S n)) = fib n + fib (S n)


来源:https://stackoverflow.com/questions/43878995/in-idris-how-do-i-hide-something-defined-in-prelude

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!