module Haskus.Format.Binary.Layout
( LayoutPathType
, LayoutPathOffset
, LayoutRoot
, LayoutPath (..)
, LayoutIndex (..)
, LayoutSymbol (..)
, layoutIndex
, layoutSymbol
, (:->)
, (:#>)
)
where
import Haskus.Utils.Types
import Haskus.Utils.Types.List
data LayoutPath (path :: [*]) = LayoutPath
data LayoutIndex (n :: Nat) = LayoutIndex
data LayoutSymbol (s :: Symbol) = LayoutSymbol
layoutIndex :: forall n. LayoutPath '[LayoutIndex n]
layoutIndex = LayoutPath
layoutSymbol :: forall s. LayoutPath '[LayoutSymbol s]
layoutSymbol = LayoutPath
type family LayoutPathType l p :: *
type instance LayoutPathType l (LayoutPath '[]) = l
type family LayoutPathOffset l p :: Nat
type instance LayoutPathOffset e (LayoutPath '[]) = 0
type LayoutRoot = LayoutPath '[]
type family (:->) p (s :: Symbol) where
(:->) (LayoutPath xs) s = LayoutPath (Snoc xs (LayoutSymbol s))
type family (:#>) p (n :: Nat) where
(:#>) (LayoutPath xs) n = LayoutPath (Snoc xs (LayoutIndex n))