{-# LANGUAGE CPP, DataKinds, GeneralizedNewtypeDeriving, PatternSynonyms,
KindSignatures, ScopedTypeVariables, TypeFamilies,
TypeOperators #-}
module Frames.Col where
import Data.Vinyl (ElField(Field), getField)
import GHC.TypeLits
type (a :: Symbol) :-> b = '(a,b)
pattern Col :: KnownSymbol s => t -> ElField '(s,t)
pattern Col x = Field x
getCol :: ElField '(s, t) -> t
getCol = getField
newtype Col' s a = Col' (ElField (s :-> a))
col' :: KnownSymbol s => a -> Col' s a
col' = Col' . Field
instance (KnownSymbol s, Show a) => Show (Col' s a) where
show (Col' c) = "(" ++ show c ++ ")"
type family ReplaceColumns x ys where
ReplaceColumns x '[] = '[]
ReplaceColumns x (c :-> y ': ys) = c :-> x ': ReplaceColumns x ys