Created
March 7, 2011 17:51
-
-
Save maoe/858876 to your computer and use it in GitHub Desktop.
MPTCs + fundepsとtype familiesは型の上の関数
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 UndecidableInstances, FlexibleInstances #-} | |
{-# LANGUAGE TypeFamilies, FunctionalDependencies, MultiParamTypeClasses #-} | |
data Z | |
data S n | |
class Plus m n r | m n -> r | |
instance Plus Z n n | |
instance Plus m n r => Plus (S m) n (S r) | |
two = undefined :: Plus (S Z) (S Z) r => r | |
type family Plus' m n :: * | |
type instance Plus' Z n = n | |
type instance Plus' (S m) n = S (Plus' m n) | |
two' = undefined :: Plus' (S Z) (S Z) | |
{- | |
Prelude> :t two | |
two :: S (S Z) | |
Prelude> :t two' | |
two' :: S (S Z) | |
-} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment