{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleInstances #-}
module Data.Tapioca.Internal.Types.Index where
import Data.Kind
import GHC.TypeLits
class Width t where
width :: t -> Int
class Index t (s :: Symbol) where
index :: t -> Int
class PickNext (t1 :: Type) (t2 :: Type) (m :: Bool) where
type Next t1 t2 m :: Type
incr :: t1 -> Int
next :: t1 -> t2 -> Next t1 t2 m
instance PickNext t1 t2 'True where
type Next t1 t2 'True = t1
incr _ = 0
next t1 _ = t1
instance Width t1 => PickNext t1 t2 'False where
type Next t1 t2 'False = t2
incr = width
next _ t2 = t2