Last active
August 29, 2015 14:02
-
-
Save LeifW/aacd29f5336d19eea230 to your computer and use it in GitHub Desktop.
Use of postulate in Idris typeclass law
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
%default total | |
class Semigroupy a where | |
op: a -> a -> a | |
semigroupOpIsAssociative : (x, y, z : a) -> op x (op y z) = op (op x y) z | |
instance Semigroupy Int where | |
op = (+) | |
semigroupOpIsAssociative x y z = believe_me "sure, yeah, whatever" | |
{- | |
A problem with that is that now the value of the proof is that string. | |
Which could break anything expecting the more usual value, "refl". | |
Using "postulate" instead doesn't have that problem, because it doesn't reduce (no value). | |
-} | |
instance Semigroupy Integer where | |
op = (+) | |
semigroupOpIsAssociative x y z = integerAssociative | |
where postulate integerAssociative : x + (y + z) = (x + y) + z |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks such much for this, Leif.