Created
December 11, 2012 10:27
-
-
Save xenophobia/4257599 to your computer and use it in GitHub Desktop.
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
{-# Language GADTs, KindSignatures, DataKinds, TypeOperators, TypeFamilies #-} | |
data Nat = Zero | Succ Nat | |
data SNat (n :: Nat) where | |
SZero :: SNat 'Zero | |
SSucc :: SNat m -> SNat ('Succ m) | |
type family NIntArrow (a :: Nat) | |
type instance NIntArrow 'Zero = Int | |
type instance NIntArrow ('Succ n) = Int -> NIntArrow n | |
addN :: SNat nat -> NIntArrow nat | |
addN n = addN' n 0 | |
where | |
addN' :: SNat nat -> Int -> NIntArrow nat | |
addN' SZero acc = acc | |
addN' (SSucc n') acc = \x -> addN' n' (acc+x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment