Skip to content

Instantly share code, notes, and snippets.

@pedrominicz
Last active September 21, 2019 19:01
Show Gist options
  • Save pedrominicz/0c049bda74368553e24a3a8d38f67006 to your computer and use it in GitHub Desktop.
Save pedrominicz/0c049bda74368553e24a3a8d38f67006 to your computer and use it in GitHub Desktop.
Haskell doodle made while reading about Twelf.
-- 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