Created
August 2, 2013 00:04
-
-
Save david-christiansen/6136455 to your computer and use it in GitHub Desktop.
Using type classes for logic programming
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 Addition | |
class Plus (n : Nat) (m : Nat) (o : Nat) where {} | |
instance Plus Z m m where {} | |
instance Plus n m o => Plus (S n) m (S o) where {} | |
parameters (n : Nat, m : Nat) | |
using (o : Nat) | |
myplus : (Plus n m o) => Nat | |
myplus {o = o} = o | |
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
*Addition> myplus 2 4 | |
6 : Nat | |
*Addition> myplus 90 2 | |
92 : Nat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment