golem icon indicating copy to clipboard operation
golem copied to clipboard

`hseq` as convolution of struct

Open fogfish opened this issue 6 months ago • 0 comments

Existing hseq implementation supports extractions either using either type or attribute hints

type T struct {
  A A
  B B
}

seq = hseq.New[T]()
hseq.ForType[T, A](seq)
hseq.ForName[T](seq, "B")

It suffers from type definition when type is repeated multiple times in the struct, only attribute hint shall be used.

type T struct {
  A1 A
  A2 A
  B1 B
  B2 B
  A3 A
}

However, it makes hseq less usable and dependent on field names. Idea is using the type proposition as an abstraction

hlist.New[T, A, A, B, B, A]()

It makes a proper definition of the shape A :: A :: B :: B :: A :: nil without actual knowledge of attribute names.

fogfish avatar Aug 02 '25 20:08 fogfish