module RlangQQ.MakeRecord where
import GHC.TypeLits
import Control.Monad.State
import Control.Monad.Identity
import Data.HList.CommonMain
import HListExtras
listToRecN :: ListToRecN __ (n :: HNat) x r => Proxy n -> [x] -> Record r
listToRecN n xs = Record $ hMap NoLabel $ flip evalState xs $ hSequence $ hReplicate n comp
where comp = do
x : xs' <- get
return () :: State [x] ()
put (xs' `asTypeOf` xs)
return (x `asTypeOf` head xs)
type ListToRecN __ (n :: HNat) x r = (HReplicate n (StateT [x] Identity x),
HSequence (StateT [x] Identity) (HReplicateR n (StateT [x] Identity x)) __,
HMapCxt NoLabel (HList __) (HList r) __ r)
data NoLabel = NoLabel
instance (Tagged "" a ~ la) => ApplyAB NoLabel a la where
applyAB _ x = Tagged x