Last active
May 10, 2016 20:19
-
-
Save raichoo/2bbbbd0c8dae5f7a4620a043ff72cb54 to your computer and use it in GitHub Desktop.
Oh… this works.
This file contains hidden or 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
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE GADTs #-} | |
module PlusZero where | |
import Data.Type.Equality | |
data Nat | |
= Zero | |
| Succ Nat | |
type family Plus (n :: Nat) (m :: Nat) :: Nat where | |
Plus 'Zero m = m | |
Plus ('Succ n) m = 'Succ (Plus n m) | |
data SNat (n :: Nat) where | |
SZero :: SNat 'Zero | |
SSucc :: SNat n -> SNat ('Succ n) | |
congSucc :: a :~: b -> 'Succ a :~: 'Succ b | |
congSucc Refl = Refl | |
plusZero :: SNat n -> Plus n 'Zero :~: n | |
plusZero SZero = Refl | |
plusZero (SSucc n) = congSucc (plusZero n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment