{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeInType #-}
{-# OPTIONS_HADDOCK not-home #-}
module Optics.Internal.Optic.TypeLevel where
import Data.Kind (Type)
import GHC.TypeLits
type IxList = [Type]
type NoIx = ('[] :: IxList)
type WithIx i = ('[i] :: IxList)
type family QuoteType (x :: Type) :: ErrorMessage where
QuoteType x = 'Text "‘" ':<>: 'ShowType x ':<>: 'Text "’"
type family Curry (xs :: IxList) (y :: Type) :: Type where
Curry '[] y = y
Curry (x ': xs) y = x -> Curry xs y
type family Append (xs :: IxList) (ys :: IxList) :: IxList where
Append '[] ys = ys
Append xs '[] = xs
Append (x ': xs) ys = x ': Append xs ys
class CurryCompose xs where
composeN :: (i -> j) -> Curry xs i -> Curry xs j
instance CurryCompose '[] where
composeN = id
{-# INLINE composeN #-}
instance CurryCompose xs => CurryCompose (x ': xs) where
composeN ij f = composeN @xs ij . f
{-# INLINE composeN #-}