Created
May 9, 2014 21:08
-
-
Save gbluma/dd6dea90141fa21845ea to your computer and use it in GitHub Desktop.
A simple example showing how divide by zero can be restricted in Idris
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main | |
%default total | |
myDivide : Nat -> (y:Nat) -> so (y /= 0) -> Nat | |
myDivide x y p = div x y | |
main : IO () | |
main = | |
print (show (myDivide 3 1 oh)) -- compiles successfully | |
-- print (show (myDivide 3 0 oh)) -- throws an error at compile time |
I expect Idris has changed a bit in the last 7 years. I wouldn't consider bit of code to be accurate to the language any more.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
No such variable so
Is that the expected behaviour? 🤔