ADPfusion-0.5.1.0: Efficient, high-level dynamic programming.

Safe HaskellNone
LanguageHaskell2010

ADP.Fusion.Base.TyLvlIx

Description

Type-level indexing functionality

Synopsis

Documentation

class GetIndexGo ixTy myTy cmp where Source

Given some complete index list ixTy and some lower-dimensional version myTy, walk down along ixTy until we have is:.i ~ ms:.m and return m.

Associated Types

type ResolvedIx ixTy myTy cmp :: * Source

Methods

getIndexGo :: ixTy -> Proxy myTy -> Proxy cmp -> ResolvedIx ixTy myTy cmp Source

type GetIndex l r = GetIndexGo l r (CmpNat (ToNat l) (ToNat r)) Source

Wrap GetIndexGo and the type-level shenanigans.

type GetIx l r = ResolvedIx l r (CmpNat (ToNat l) (ToNat r)) Source

getIndex :: forall ixTy myTy. GetIndex ixTy myTy => ixTy -> Proxy myTy -> GetIx ixTy myTy Source

Simplifying wrapper around getIndexGo.

type family ToNat x :: Nat Source

Given some index structure x, return the dimensional number in Nats.

Instances

type ToNat Z = 0 Source 
type ToNat (RunningIndex Z) = 0 Source 
type ToNat (RunningIndex ((:.) is i)) = (+) (ToNat (RunningIndex is)) 1 Source 
type ToNat ((:.) is i) = (+) (ToNat is) 1 Source