Last active
September 21, 2019 19:01
-
-
Save pedrominicz/0c049bda74368553e24a3a8d38f67006 to your computer and use it in GitHub Desktop.
Haskell doodle made while reading about Twelf.
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
-- Haskell doodle made while reading about Twelf. | |
-- http://twelf.org/wiki/Proving_metatheorems_with_Twelf | |
module Twelf where | |
data Nat | |
= Zero | |
| Succ Nat | |
deriving (Eq, Show) | |
class Even a where | |
isEven :: a -> Bool | |
instance Even Nat where | |
isEven Zero = True | |
isEven (Succ (Succ x)) = isEven x | |
isEven _ = False | |
class Plus a where | |
plus :: a -> a -> a -> Bool | |
instance Plus Nat where | |
plus Zero y z = y == z | |
plus (Succ x) y (Succ z) = plus x y z | |
one = Succ Zero | |
two = Succ one | |
three = Succ two | |
four = Succ three | |
five = Succ four |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment