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.
Asked
Active
Viewed 856 times
8

Neil Mitchell
- 9,090
- 1
- 27
- 85
1 Answers
8
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)

Anton Trunov
- 15,074
- 2
- 23
- 43
-
Thanks. Is there any documentation on what %hide does? – Neil Mitchell May 10 '17 at 06:20
-
No, not really. There is this [syntax guide](https://github.com/idris-lang/Idris-dev/blob/fb9a5ec0080020b5289a95658920ab9524be39b0/docs/reference/syntax-guide.rst#L470) and this [mailing list post](https://groups.google.com/d/msg/idris-lang/fRQxu6EuUgM/nuWQmjL-svAJ). – Anton Trunov May 10 '17 at 06:44
-
The syntax guide isn't very helpful - my guess was it was for hiding something I was exporting, not importing... – Neil Mitchell May 10 '17 at 10:23