Only a small supplement: If we generalize such an ordinary constraint, i.e. make the value constructor (the NonEmpty portion of NonEmpty<A>) itself polymorphic, we obtain a type class constraint. Since TS doesn't support type constructors like T<A> we can use dictionary passing style (pass the type class constraint as a normal argument to the polymorphic function) or resort to HKT hacks as pursued by FP-TS.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Only a small supplement: If we generalize such an ordinary constraint, i.e. make the value constructor (the
NonEmpty
portion ofNonEmpty<A>
) itself polymorphic, we obtain a type class constraint. Since TS doesn't support type constructors likeT<A>
we can use dictionary passing style (pass the type class constraint as a normal argument to the polymorphic function) or resort to HKT hacks as pursued by FP-TS.