{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE AllowAmbiguousTypes #-}
module Haskus.Format.Binary.Layout
( LPath (..)
, PathElem (..)
, lPath
, LPathType
, LPathOffset
, LRoot
, (:->)
, (:#>)
)
where
import Haskus.Utils.Types
data LPath (path :: [PathElem]) = LPath
data PathElem
= LIndex Nat
| LSymbol Symbol
type LRoot = LPath '[]
lPath :: forall e. LPath '[e]
lPath = LPath
type family LPathType p l :: *
type instance LPathType (LPath '[]) l = l
type family LPathOffset p l :: Nat
type instance LPathOffset (LPath '[]) l = 0
type family (:->) p (s :: Symbol) where
(:->) (LPath xs) s = LPath (Snoc xs ('LSymbol s))
type family (:#>) p (n :: Nat) where
(:#>) (LPath xs) n = LPath (Snoc xs ('LIndex n))