The natToFin
function from the standard library has the following signature:
natToFin : Nat -> (n : Nat) -> Maybe (Fin n)
natToFin 4 5
returns Just (FS (FS (FS (FS FZ)))) : Maybe (Fin 5)
, while
natToFin 5 5
returns Nothing
.
I would like a function with the following signature:
myNatToFin : (m : Nat) -> (n : Nat) -> { auto p : n `GT` m } -> Fin n
It behaves the same as the standard lib function but doesn't need to return a Maybe
because it is always possible to generate a Fin n
from m
given that n
is greater than m
.
How do I implement myNatToFin
?