Created
August 18, 2014 19:12
-
-
Save k-bx/a7b49165399658f87358 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 TypeFamilies #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
import GHC.TypeLits | |
import Data.Proxy | |
type family Last (a :: (Nat -> *)) :: Nat | |
newtype VJ (t :: Nat -> *) (v :: Nat) = VJ Int | |
data D (v :: Nat) | |
class Op (t :: Nat -> *) (v :: Nat) where | |
f :: VJ t v -> VJ t (Last t) | |
instance Op D 0 where | |
f (VJ i) = f (VJ i :: VJ D (0+1)) | |
instance Op D 1 where | |
f (VJ i) = VJ i | |
main = do | |
putStrLn "hello" | |
data Zero | |
data Succ a | |
type family Last' (a :: (* -> *)) :: * | |
data D' v | |
type instance Last' D' = Succ Zero | |
newtype VJ' (t :: * -> *) v = VJ' Int | |
class Op' (t :: * -> *) v where | |
f' :: VJ' t v -> VJ' t (Last' t) | |
instance Op' D' Zero where | |
f' (VJ' i) = f' (VJ' i :: VJ' D' (Succ Zero)) | |
instance Op' D' (Succ Zero) where | |
f' (VJ' i) = VJ' i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment