Last active
October 1, 2016 02:42
-
-
Save oliver-batchelor/247118bc6f15badbcf05b3abc94830f9 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 TemplateHaskell, FlexibleContexts, FlexibleInstances, GADTs, DataKinds, | |
TypeInType, KindSignatures, InstanceSigs, TypeOperators, | |
ConstraintKinds, RankNTypes, ScopedTypeVariables, TypeFamilies, | |
UndecidableInstances, MultiParamTypeClasses, TypeApplications, PartialTypeSignatures #-} | |
$(singletons [d| | |
data UNat = Zero | Succ UNat | |
deriving (Eq) | |
|]) | |
class Concats (d:: UNat) (xs::[Nat]) (ys::[Nat]) where | |
type ConcatShape d xs ys :: [Nat] | |
instance (xs ~ ys) => Concats 'Zero (x:xs) (y:ys) where | |
type ConcatShape Zero (x:xs) (y:_) = (x + y : xs) | |
instance (x ~ y) => Concats ('Succ n) (x:xs) (y:ys) where | |
type ConcatShape (Succ n) (x:xs) (_:ys) = x : ConcatShape n xs ys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment