Last active
January 14, 2022 13:40
-
-
Save lolepezy/30820595afd9217083c5ca629e350b55 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 TypeOperators #-} | |
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE GADTs #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
{-# LANGUAGE PolyKinds #-} | |
{-# LANGUAGE UndecidableInstances #-} | |
{-# LANGUAGE MultiParamTypeClasses #-} | |
{-# LANGUAGE TypeFamilies #-} | |
{-# LANGUAGE FunctionalDependencies #-} | |
module TList where | |
import Data.Proxy | |
data TList (ixs :: [*]) (f :: * -> *) where | |
TNil :: TList '[] f | |
(:-:) :: f ix -> TList ixs f -> TList (ix ': ixs) f | |
infixr 5 :-: | |
class TListGen ixs (g :: * -> *) where | |
genTList :: Proxy ixs -> g ix -> TList ixs g | |
instance TListGen '[] g where | |
genTList _ _ = TNil | |
instance {-# OVERLAPS #-} TListGen ixs g => TListGen (ix ': ixs) g where | |
genTList pixs g = g :-: genTList (proxyTail pixs) g | |
proxyTail :: Proxy (z ': zs) -> Proxy zs | |
proxyTail _ = Proxy |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment