@@ -129,6 +129,8 @@ natToFin (S k) (S j) with (natToFin k j)
129 | Nothing = Nothing
129 | Nothing = Nothing
130natToFin _ _ = Nothing
130natToFin _ _ = Nothing
132+||| Convert an `Integer` to a `Fin`, provided the integer is within bounds.
133+||| @n The upper bound of the Fin
132integerToFin : Integer -> (n : Nat) -> Maybe (Fin n)
134integerToFin : Integer -> (n : Nat) -> Maybe (Fin n)
133integerToFin x Z = Nothing -- make sure 'n' is concrete, to save reduction!
135integerToFin x Z = Nothing -- make sure 'n' is concrete, to save reduction!
134integerToFin x n = if x >= 0 then natToFin (cast x) n else Nothing
136integerToFin x n = if x >= 0 then natToFin (cast x) n else Nothing