haskus-utils-0.8.0.0: Haskus utility modules

Safe HaskellNone
LanguageHaskell2010

Haskus.Utils.HArray

Description

Heterogeneous array: like a HList but indexed in O(1)

Synopsis

Documentation

data HArray (types :: [*]) Source #

heterogeneous array

type HArrayIndex (n :: Nat) t (ts :: [*]) = (KnownNat n, t ~ Index n ts, KnownNat (Length ts), CmpNat n (Length ts) ~ LT) Source #

The type t with index n is indexable in the array

type HArrayIndexT t (ts :: [*]) = (IsMember t ts ~ True, HArrayIndex (IndexOf t ts) t ts) Source #

A type t is indexable in the array

type HArrayTryIndexT t (ts :: [*]) = HArrayIndex (MaybeIndexOf t ts) t (t ': ts) Source #

A type t is maybe indexable in the array

emptyHArray :: HArray '[] Source #

Empty array

singleHArray :: a -> HArray '[a] Source #

Empty array

getHArrayN :: forall (n :: Nat) (ts :: [*]) t. HArrayIndex n t ts => HArray ts -> t Source #

Get an element by index

getHArray0 :: HArrayIndex 0 t ts => HArray ts -> t Source #

Get first element

setHArrayN :: forall (n :: Nat) (ts :: [*]) t. HArrayIndex n t ts => t -> HArray ts -> HArray ts Source #

Set an element by index

getHArrayT :: forall t ts. HArrayIndexT t ts => HArray ts -> t Source #

Get an element by type (select the first one with this type)

setHArrayT :: forall t ts. HArrayIndexT t ts => t -> HArray ts -> HArray ts Source #

Set an element by type (select the first one with this type)

tryGetHArrayT :: forall t ts. HArrayTryIndexT t ts => HArray ts -> Maybe t Source #

Get an element by type (select the first one with this type)

appendHArray :: HArray ts -> t -> HArray (Snoc ts t) Source #

Append a value to an array (O(n))

prependHArray :: t -> HArray ts -> HArray (t ': ts) Source #

Prepend a value to an array (O(n))

concatHArray :: HArray ts1 -> HArray ts2 -> HArray (Concat ts1 ts2) Source #

Concat arrays

initHArray :: HArray ts -> HArray (Init ts) Source #

Drop the last element

tailHArray :: HArray ts -> HArray (Tail ts) Source #

Drop the first element

newtype HArrayT m xs ys Source #

Constructors

HArrayT 

Fields

(>~:~>) :: Monad m => HArrayT m xs ys -> HArrayT m ys zs -> HArrayT m xs zs Source #

Compose HArrayT