{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE PolyKinds #-}
module Generics.MRSOP.GDiff.Util where
import Generics.MRSOP.Base hiding (listPrfNP)
import Generics.MRSOP.Util ((:++:))
type L1 xs = (IsList xs)
type L2 xs ys = (IsList xs, IsList ys)
type L3 xs ys zs = (IsList xs, IsList ys, IsList zs)
type L4 xs ys zs as = (IsList xs, IsList ys, IsList zs, IsList as)
data RList :: [k] -> * where
RList :: IsList ts => RList ts
{-# INLINE reify #-}
reify :: ListPrf ts -> RList ts
reify LP_Nil = RList
reify (LP_Cons x) = case reify x of RList -> RList
listPrfNP :: NP p xs -> ListPrf xs
listPrfNP Nil = LP_Nil
listPrfNP (_ :* xs) = LP_Cons $ listPrfNP xs
split :: ListPrf xs -> NP p (xs :++: ys) -> (NP p xs, NP p ys)
split LP_Nil poa = (Nil, poa)
split (LP_Cons p) (x :* rs) =
let (xs, rest) = split p rs
in (x :* xs, rest)